--
You received this message because you are subscribed to the Google Groups "oversim" group.
To post to this group, send email to ove...@googlegroups.com.
To unsubscribe from this group, send email to oversim+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/oversim?hl=en.
> Unfortunately, I am quite new to C++ as an programming language and have
> apparently created one (or more) memory leaks.
>
> Can anybody point me in the general direction where it would be most likely
> to that these occur. I found some help in the OMNeT++/OMNEST Manual
> (Section 8.11.2) and applied the fixes mentioned there. Unfortunately,
> there must be more :(
>
> The problem especially shows itself when I use many repetitions and my RAM
> slowly but steadily fills up with each run.
Use valgrind. This tool has a memory checker that will tell you where memory
is allocated that is never freed.
Regards,
Stephan
> Anyway, I found out that the problem was the XML plugin.
> I had disabled line 307-311 in SimpleUnderlayConfigurator.cc.
> #if OMNETPP_VERSION>=0x0401
> // free memory used for xml document
> ev.forgetXMLDocument(nodeCoordinateSource);
> malloc_trim(0);
> #endif
Please try to only disable the malloc_trim line, and keep the rest. (I've no
access to a mac, so that's untested, but it should work)
Regards,
Stephan
OK, so I'll elaborate a bit, too. If you disable the whole block, the memory
for the coordfile, which is parsed on the begin of every run, is never freed,
i.e. your memory consumption increases if you run multiple runs.
If you only disable the malloc_trim call, the memory will be marked free, but
not immediately released. However, it will be re-used eventually, so there is
no real memory leak. Basically, if you change the block to
#if OMNETPP_VERSION>=0x0401
// free memory used for xml document
ev.forgetXMLDocument(nodeCoordinateSource);
#if !defined(__APPLE__) && !defined(_WIN32)
malloc_trim(0);
#endif
#endif
you will 1. have everything as usual on Linux and 2. have no real memory leak
on OS X and Windows, too.
Regards,
Stephan
Thank you Stephan, in that context your solution is much more elegant.