Hi Thomas,
I did a quick read of your code, and the first thing I notice is that
the osgDB::readNodeFile result is assigned to a osg::Group*, NOT a
osg::ref_ptr<osg::Group> . The pointers run out of scope at the end of
"generateSimplifiedNodes", mergeNodes seems to take most of the
geometry, but this looks like a leak to me.
Laurens.
On 5/2/2010 8:07 PM, Tomas Hnilica wrote:
Hello OSG users,
I am working on a project that processes large amount of data a have
problems with memory leaks.
Problematic part of the code does simplification of OSG subgraphs and
writes out the results.
In this code, no graphical window exists, it's only about reading -
processing - writing of .ive files.
The code reads in two .ive files, merges the geometries in these files,
does simplification on the merged geometries and writes the result to
the .ive file.
On very large models the system goes out of memory in the simplification
phase. There must be some memory leak in the code, I guess in the
merging phase, because this is done by myself :)
During the process in the single simplification step, the memory is
allocated and then deallocated, but not to the same amount as before
(that may be OS allocation strategy specific). When the process goes
through several simplification steps, the amount of overall reserved
memory increases (this is what MS Windows task manager says).
I tried to find the problem with valgrind on Linux, but it reports loss
of memory in the OSG code, what is probably wrong interpretation. Does
anynone use valgrind for memory leak detection in OSG apps or can you
recommend other method?
I attached simplified snapshot of incremented piece of my code, if
different eyes could have a short look I would highly appreciate it -
maybe there is only wrong usage of readNodeFiles, merging data or
osg::ref_ptr's...it seems that only small portion of the allocated
memory is not deallocated.
Some messages coming from valgrind that are not clear to me (I hope OSG
is memory leak free because of osg::ref_ptr ):
------------------------------------------------------------------------------------------------------------------------
==11693== 12,137 (328 direct, 11,809 indirect) bytes in 1 blocks are
definitely lost in loss record 287 of 432
==11693== at 0x4C23809: operator new(unsigned long)
(vg_replace_malloc.c:230)
==11693== by 0x56B7D09: osg::Node::getOrCreateStateSet() (in
/home/tomas/OpenSceneGraph-2.8.0/lib/libosg.so.2.8.0)
==11693== by 0x5EF992D: osgFX::Effect::build_dummy_node() (in
/home/tomas/OpenSceneGraph-2.8.0/lib/libosgFX.so.2.8.0)
==11693== by 0x5EFA072: osgFX::Effect::Effect() (in
/home/tomas/OpenSceneGraph-2.8.0/lib/libosgFX.so.2.8.0)
==11693== by 0x5EFCDDF: osgFX::Scribe::Scribe() (in
/home/tomas/OpenSceneGraph-2.8.0/lib/libosgFX.so.2.8.0)
==11693== by 0x2989BE06: ???
==11693== 17,616 (1,560 direct, 16,056 indirect) bytes in 15 blocks are
definitely lost in loss record 286 of 432
==11693== at 0x4C23809: operator new(unsigned long)
(vg_replace_malloc.c:230)
==11693== by 0x6BD87C1: EdgeCollapse::addEdge(EdgeCollapse::Triangle*,
EdgeCollapse::Point*, EdgeCollapse::Point*) (in
/home/tomas/OpenSceneGraph-2.8.0/lib/libosgUtil.so.2.8.0)
==11693== by 0x6BDB815: EdgeCollapse::addTriangle(EdgeCollapse::Point*,
EdgeCollapse::Point*, EdgeCollapse::Point*) (in
/home/tomas/OpenSceneGraph-2.8.0/lib/libosgUtil.so.2.8.0)
==11693== by 0x6BDD72D: EdgeCollapse::collapseEdge(EdgeCollapse::Edge*,
EdgeCollapse::Point*) (in
/home/tomas/OpenSceneGraph-2.8.0/lib/libosgUtil.so.2.8.0)
==11693== by 0x6BCD03D: osgUtil::Simplifier::simplify(osg::Geometry&,
std::vector<unsigned, std::allocator<unsigned> > const&) (in
/home/tomas/OpenSceneGraph-2.8.0/lib/libosgUtil.so.2.8.0)
==11693== by 0x6BCD456: osgUtil::Simplifier::simplify(osg::Geometry&)
(in /home/tomas/OpenSceneGraph-2.8.0/lib/libosgUtil.so.2.8.0)
-------------------------------------------------------------------------------------------------------------------------
The linux code is OSG 2.8.0, I tested the same with 2.9.7 as well.
Thank you very much for any comments and help in advance,
Tomas Hnilica
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org