Hi Laurens, Hi Jason,
thank you very much, the osg::ref_ptr on osgDB::readNodeFile helped! In
almost all OSG examples reading node from the file is done without
ref_ptr, that is why I did it too. After using ref_ptr many of the leaks
detected are gone.
Jason, you are right, I had to recompile the osg lib with debug options
to get more accurate results.
Anyway there are some records in valgrind that I cannot identify and may
be interesing:
==867== 9,150 bytes in 242 blocks are possibly lost in loss record 329
of 365
==867== at 0x4C23809: operator new(unsigned long)
(vg_replace_malloc.c:230)
==867== by 0xC06B2E0: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.9)
==867== by 0xC06BCBA:
std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long)
(in /usr/lib/libstdc++.so.6.0.9)
==867== by 0xC06C60F: std::string::reserve(unsigned long) (in
/usr/lib/libstdc++.so.6.0.9)
==867== by 0xC06C76C: std::string::append(unsigned long, char) (in
/usr/lib/libstdc++.so.6.0.9)
==867== by 0x2A4DE24C: ive::DataInputStream::readString()
(DataInputStream.cpp:445)
==867== by 0x2A540ACC: ive::Object::read(ive::DataInputStream*)
(Object.cpp:65)
==867== by 0x2A53EAF3: ive::Node::read(ive::DataInputStream*)
(Node.cpp:115)
==867== by 0x2A5327AC: ive::Group::read(ive::DataInputStream*)
(Group.cpp:61)
==867== by 0x2A558A70: ive::Switch::read(ive::DataInputStream*)
(Switch.cpp:48)
==867== by 0x2A4DF3F5: ive::DataInputStream::readNode()
(DataInputStream.cpp:1768)
==867== by 0x2A532891: ive::Group::read(ive::DataInputStream*)
(Group.cpp:74)
I guess this is a possible memory leak in osgDB::DatabasePager caused
==867== 608 bytes in 2 blocks are possibly lost in loss record 266 of 365
==867== at 0x4C220BC: calloc (vg_replace_malloc.c:397)
==867== by 0x401134B: _dl_allocate_tls (in /lib/ld-2.7.so)
==867== by 0xB898B87: pthread_create@@GLIBC_2.2.5 (in
/lib/libpthread-2.7.so)
==867== by 0x69DFF07: OpenThreads::Thread::start() (PThread.c++:637)
==867== by 0x69DFF67: OpenThreads::Thread::startThread()
(PThread.c++:657)
==867== by 0x704CFC9:
osgDB::DatabasePager::requestNodeFile(std::string const&, osg::Group*,
float, osg::FrameStamp const*, osg::ref_ptr<osg::Referenced>&,
osg::Referenced const*) (DatabasePager.cpp:1386)
==867== by 0x5A0BDA4: osg::PagedLOD::traverse(osg::NodeVisitor&)
(PagedLOD.cpp:226)
==867== by 0x591646A: osg::NodeVisitor::traverse(osg::Node&)
(NodeVisitor:191)
==867== by 0x758B796:
osgUtil::CullVisitor::handle_cull_callbacks_and_traverse(osg::Node&)
(CullVisitor:300)
==867== by 0x7585DB3: osgUtil::CullVisitor::apply(osg::LOD&)
(CullVisitor.cpp:1071)
==867== by 0x59FA5B7: osg::NodeVisitor::apply(osg::PagedLOD&)
(NodeVisitor.cpp:161)
==867== by 0x5A0CB73: osg::PagedLOD::accept(osg::NodeVisitor&)
(PagedLOD:32)
Many thanks for your help!
Tomas
Laurens Voerman napsal(a):
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.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org