[Lazarus] Memory leak with Synchronize on external threads

Stefan Schalk schalk.stefan at googlemail.com
Thu May 26 11:06:39 CEST 2016


There is a memory consumption/leak using the TThread.Synchronize function.

A callback function is called out of another ("external") thread (from an
loaded DLL).
Inside the callback function a synchronized call to a procedure has to be
done.
Every thing works without error, but there is a memory use increasement
during the TThread.Synchronize call.

procedure OnExternalThreadCallback(...); cdecl;
begin
  ...
  TThread.Synchronize(nil, @MyMainClass.CallbachSyncedWithMainThread);
  ...
end;

The external thread are created/used/freed like discussed in the Lazarus
mailing list:
Mutlithreaded Dll Callback crashes my Application
<http://lists.lazarus.freepascal.org/pipermail/lazarus/2010-August/054728.html>

The memory leak problem arises with Lazarus 1.6.0 and FPC 3.0.0.
Under the hood the processing of the TThread.Synchronize changed.
Lazarus 1.4.4 with FPC 2.6.4 didn't have this problem.
I don't have the versions between 1.4.4 and 1.6.0, therefore I cannot say
something about them (if there are any).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160526/30d82966/attachment-0002.html>


More information about the Lazarus mailing list