Hi Jean Sebastion,
If your application run on linux plateform you can try valgrind, it will
give you a lot of informations about leaks and more.
Cheers,
Cedric
Jean-Sébastien Guay wrote:
Hello all,
I am currently chasing memory leaks in our application, which is like
a modeling tool where the user will open/work on/save/close data files
multiple times during the same application run. What we are seeing is
that when a file is closed, not all memory related to scene graph
objects seems to be released.
First question:
I enabled the DEBUG_OBJECT_ALLOCATION_DESTRUCTION define in
src/osg/Referenced.cpp, and have set up a small test which just
creates two viewers one after the other in different scopes. Pseudocode:
int main(int argc, char** argv)
{
int bob = 1; // breakpoint #1
{
osgViewer::Viewer viewer;
osg::ref_ptr<osg::Node> loadedModel =
osgDB::readNodeFile("cow.osg");
viewer.setSceneData( loadedModel.get() );
viewer.run();
}
bob = 2; // breakpoint #2
{
osgViewer::Viewer viewer;
osg::ref_ptr<osg::Node> loadedModel =
osgDB::readNodeFile("cow.osg");
viewer.setSceneData( loadedModel.get() );
viewer.run();
}
bob = 3; // breakpoint #3
}
What I see is this (all in debug):
Breakpoint #1 : 8 Referenced objects, 12MB
First viewer run : ~505 Referenced objects, 266MB
Breakpoint #2 : 247 Referenced objects, 167MB
Second viewer run : ~505 Referenced objects, 266MB
Breakpoint #3 : 247 Referenced objects, 172MB
But then, when I pass breakpoint #3, all the destructors for those
Referenced objects are called, and at the end no objects are left
allocated. (I can see that the final number of objects is 0)
Other than seeing that there are no real "leaks" per se, my question
about that is, what are those objects that are staying alive outside
the scopes? I would have thought that most objects would only live in
one of the viewer scopes above, 247 seems pretty large to me...
Second question:
Our application apparently has memory leaks, because when closing a
file and opening the same one again, the application takes about 20MB
more each time (i.e. memory usage is ~100MB with a file open, then
~50MB when it's closed, then ~120MB when it's opened again, then ~70MB
when it's closed again, then ~140MB when it's opened again, and so on).
However, running IBM Purify on the application reveals no massive
leaks, only a few false positives. Are there any tools or techniques
that someone could recommend to make finding and fixing memory leaks
easy, and which work well with OSG? I tried Visual Leak Detector which
is open source, but it reported so many false positives related to
variables stored in ref_ptrs (over 400) that I gave up on it.
Thanks in advance,
J-S
--
+33 (0) 6 63 20 03 56 Cedric Pinson mailto:morni...@plopbyte.net
http://www.plopbyte.net
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org