[Lemon-user] Memory management and thread-safety in LEMON
Jose Luis Marín Español
marinjl at aia.es
Tue Mar 19 22:49:52 CET 2013
Thanks very much Alpár, it's all very clear now. May I suggest that your
explanation below be added to the official documentation (at least for the
benefit of those of us who are not so familiar with RAII idioms).
BTW congratulations on such a great piece of software. I'm evaluating the
Min Cost Network Flow algorithms and the performance looks great.
JL
2013/3/19 Alpar Juttner <alpar at cs.elte.hu>
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20130319/a2c46893/attachment.html>
More information about the Lemon-user
mailing list