[Lazarus] Library, Threads and Gui

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Jun 5 09:47:02 CEST 2012

On Tue, 05 Jun 2012 09:33:53 +0200
Michael Schnell <mschnell at lumino.de> wrote:

> On 06/05/2012 08:29 AM, Mattias Gaertner wrote:
> > yes it is relevant. If you have two memory managers you can not 
> > exchange strings and classes.
> Is cmem "the way to go" to unify the memory managers of a dynamic 
> library and the calling application ? (There seem more advanced free 
> alternatives written for Delphi, that might be usable with FPC.)
> Will just "using" cmem both in the main program and in the library 
> automatically unify the memory managers ?

Under Linux: yes. I guess BSD, OS X
too. The Delphi alternatives work only on MS Windows.

> http://wiki.freepascal.org/Multithreaded_Application_Tutorial states:
>    cmem,  // the c memory manager is on some systems much faster for multi-threading
> and
> You can not use the -gh switch with the/cmem/  unit. The -gh switch uses the heaptrc unit,
> which extends the heap manager. Therefore the*heaptrc*  unit must be used*after*  the*cmem*  unit.
> Should the FPC memory manager not be more optimized for FPC code then cmem ?

Yes, it normally is.
It was slower with multithreading on some systems. The FPC heap manager
was improved for OS X. Do some tests to find out which one is better for
your application.


More information about the Lazarus mailing list