Hi Cory,
Can anybody recommend a Windows-based memory tracking tool?
I have not found any tool on Windows that gave me useful results.
Perhaps that was through lack of Google-skills or whatever, but I ended
up changing osg::Referenced to keep track of where objects were
allocated/destroyed. For a start, you can enable
#define DEBUG_OBJECT_REF_UNREF
in src/osg/Referenced.cpp and then recompile OSG and relink with your
app. This will tell you, on the command line, each time an
osg::Referenced object (or subclass) is allocated and destroyed, as well
as a count of the number of objects that are currently allocated. You
will most likely see that the count goes down to 0 at the end of your
program, meaning there are no memory leaks.
Those static objects you saw are not leaks, of course, and in my testing
I got anywhere between 40 and 300 of them in various places. You can
test by, for example, changing the osgviewer application so that the
whole main() function is enclosed in a block ( { } ) and then put a
breakpoint before and after that block. You will probably get a few
objects allocated before anything OSG is called in the main(), and about
47 OSG objects still live after the block. But all those are deleted
once you exit the app.
If you find you do have memory leaks (the memory usage of your app grows
at run time even though you shouldn't be allocating anything), then
check the osg-submissions archives for a modified osg::Referenced
header/implementation which I posted about 2 weeks ago. You can use
this to create an AllocationObserver which will be called at each ref(),
unref() and unref_nodelete() so that you can know where the call was
made. These leaks generally come from some object keeping a ref to an
object when it shouldn't, like a list/vector/map not being cleared or
whatever, so you can print out the call stack at those points, and
inspect all the results to see where the object's last ref is coming
from, for example.
But in general, as Robert said, VS's memory leak check is crap. There
are apparently ways to fix it somewhat, but even then I wouldn't trust it.
Hope this helps,
J-S
--
______________________________________________________
Jean-Sebastien Guay jean-sebastien.g...@cm-labs.com
http://www.cm-labs.com/
http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org