[Lemon-user] Memory management and thread-safety in LEMON
Alpar Juttner
alpar at cs.elte.hu
Tue Mar 19 21:38:29 CET 2013
Hi,
> I have a couple of questions about these issues, which I couldn't find
> in the Docs:
> * how is memory managed in LEMON, in general?
As usual in C++, LEMON performs explicit memory management - each
objects in LEMON takes care of cleaning up the memory allocated by
itself when it is destroyed.
> * How do I ensure that I have no leaks?
Just as in any other C++ code - if you allocate something, free it when
you do not need it anymore. Always try to use the standard STL
containers instead of allocating memory directly by hand (i.e. with
malloc()/new). The STL containers automatically free the related data
structures when the execution leaves their scope. So do all the LEMON
data structures and algorithms, of course.
> * (i.e. are there any standardized API calls to destroy all
> dynamically created objects inside the library?)
There is no such a thing and probably there is no need for it.
> * is the library thread-safe throughout?
The development version and the upcoming 1.3 release is fully thread
safe in the usual STL sense - the read operations are safe to do in
parallel, while the write operation must be guarded.
Regads,
Alpár
More information about the Lemon-user
mailing list