On 07/19/2017 02:38 AM, Fred van Stappen wrote:
> 
> It is about mse and memory leak.
> I do not find how to kill those memory leaks, it seems to me that all
> was freed before to close the mse application but I get this, how can I
> debug that ? (huh, it comes with the
> project https://github.com/fredvs/strumpract and I am sure that the
> leaks do not com from uos) :
> 
Compiled with -ghl -O- -B the Output is
"
...
Call trace for block $00007FFFF7FEF860 size 144
  $00000000006A19DD line 2054 of uos_flat.pas
  $00000000004631FE line 670 of main.pas
  $0000000000465742 line 1107 of main.pas
  $0000000000667D7A line 1011 of
../../../mseide-msegui/lib/common/widgets/mseforms.pas
  $000000000066811A line 1103 of
../../../mseide-msegui/lib/common/widgets/mseforms.pas
  $00000000004A182A line 6753 of
../../../mseide-msegui/lib/common/fpccompatibility/mclasses.pas
  $00000000004FD102 line 2269 of
../../../mseide-msegui/lib/common/kernel/mseclasses.pas
...
"
uos_flat.pas:2054 is
"
   uosPlayers[PlayerIndex] := Tuos_Player.Create();
"
-> uosPlayers[] are not freed.
"

It works for me with
"
diff --git a/src/uos_flat.pas b/src/uos_flat.pas
index 18d0860..c73cd7b 100644
--- a/src/uos_flat.pas
+++ b/src/uos_flat.pas
@@ -1794,7 +1794,9 @@ begin
    begin
 uosPlayers[PlayerIndex].Stop() ;
 {$IF DEFINED(mse)}
-  uosPlayers[PlayerIndex] := nil;
+//  uosPlayers[PlayerIndex] := nil;
+  freeandnil(uosPlayers[PlayerIndex]);
+
   uosPlayersStat[PlayerIndex] := -1 ;
  {$endif}
 end;
"

"
diff --git a/src/uos.pas b/src/uos.pas
index 03d08d7..0699c54 100644
--- a/src/uos.pas
+++ b/src/uos.pas
@@ -7844,8 +7844,8 @@ begin
  {$endif}

  {$IF DEFINED(mse)}
- thethread.terminate();
- freeandnil(self);
+// thethread.terminate();
+// freeandnil(self); //the instance is still in use!
   {$else}
   FreeOnTerminate:=True;
   terminate();
@@ -8424,7 +8424,14 @@ destructor Tuos_Player.Destroy;
 var
   x: cint32;
 begin
-
+ {$ifdef mse}
+  if thethread <> nil then begin
+   thethread.terminate();
+   application.waitforthread(thethread);
+    //calls unlockall()/relockall in order to avoid possible deadlock
+   thethread.destroy();
+  end;
+ {$endif}
   if assigned(evPause) then RTLeventdestroy(evPause);

   if length(StreamOut) > 0 then
"

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to