Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-05

Memory leak with Synchronize on external threads

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Stefan Schalk

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.freepascal.org/pipermail/lazarus/attachments/20160526/30d82966/attachment.html>

Reply by email