rchastain / eschecs

UCI chess GUI
GNU Lesser General Public License v2.1
37 stars 9 forks source link

Memory leak under Linux #30

Closed fredvs closed 5 years ago

fredvs commented 5 years ago

Hello Roland.

The memory leak comes from CommandLine

Without using CommandLine, no memory leak. Very strange because all is freed in finalization LExpr.Free;

For testing I replaced code with followed and no more memory leak.

//  if CommandLine.HasOption('coloring', LBool) then
   FColoring := LBool;
// if CommandLine.HasOption('font', LStr) then
  LFont := LStr;
//  if CommandLine.HasOption('language', LInt) then
  LLang := TLanguage(LInt);
//  if CommandLine.HasOption('movetime', LInt) then
  FMoveTime := LInt;
//  if CommandLine.HasOption('scale', LInt) then
 LScale := LInt;
//  if CommandLine.HasOption('style', LInt) then
 FStyle := TBoardStyle(LInt);
// if CommandLine.HasOption('chess960', LBool) then
 FChess960 := LBool;
rchastain commented 5 years ago

OK Fred, thank you. So there would be a problem with RegExpr unit?

I make some tests and come back to you.

Regards.

rchastain commented 5 years ago

You were right, Fred. No more memory leak, after I commented out the calls to CommandLine unit. Good! I think I will remake the unit, using another regex library. I come back to you, as soon as it is done.

fredvs commented 5 years ago

Yes, good idea, you even do not need any other regex library, ParamStr(x) is your friend.

fredvs commented 5 years ago

For example:

x := 1;
While ParamStr(x) <> '' do 
begin
   if ParamStr(x) = 'this' then dothat;
   inc(x);
end;
rchastain commented 5 years ago

Thank you Fred for the example.

I remade the CommandLine unit without using RegExpr, and the problem is still here. So I don't know what to think. I continue to investigate.

Good night!

fredvs commented 5 years ago

Maybe eschecs (like me) is not too fan of command-line parameter for a GUI app? ... Ooops, ok, ok, I go to sleep.

Good night Roland!

rchastain commented 5 years ago

I expected that you would say something like that. :)

I will think of another solution. Good night Fred!

rchastain commented 5 years ago

Hello Fred!

Done. Eschecs no longer uses the beautiful CommandLine unit. Instead of sending command parameters, the Options application overwrites eschecs.ini before starting Eschecs.

By the way, I believe I had forgotten a file in my commit of yesterday. It is repaired, and it should be possible now to start Eschecs from any directory. (I have to do the same modification in the Options application.)

I promised to do something for the eaten pieces but, as it it a new feature, maybe we could do it in a future version, 5.1.0 for example?

So, we have solved the memory leak. :)

Best regards.

Roland

fredvs commented 5 years ago

Hello Roland. Sorry for the wonderful CommandLine units. Rip. About eaten pieces, yes there is no worry. Congratulation for killing the memory leak.

Fre;D