memory leak in osgearth

304 views Asked by At

My goal is using library OSGEarth to make a MFC project that can display the model "openstreetmap.earth". I finished this and can see the the earth.But every time when i close the project, the output window in vs2015 say there are memory leaks in the program.

Here is the window output:

Detected memory leaks!
Dumping objects ->
{306240} normal block at 0x00000000076902F0, 16 bytes long.
Data: <0,i             > 30 2C 69 07 00 00 00 00 00 00 00 00 00 00 00 00 
{306239} normal block at 0x0000000007692C30, 9 bytes long.
Data: <Pragma:  > 50 72 61 67 6D 61 3A 20 00 
{303648} normal block at 0x0000000007693040, 16 bytes long.
Data: < 5i             > 90 35 69 07 00 00 00 00 00 00 00 00 00 00 00 00 
{303647} normal block at 0x0000000007693590, 9 bytes long.
Data: <Pragma:  > 50 72 61 67 6D 61 3A 20 00 
{301180} normal block at 0x00000000076938B0, 16 bytes long.
 Data: <`8i             > 60 38 69 07 00 00 00 00 00 00 00 00 00 00 00 00 
{301179} normal block at 0x0000000007693860, 9 bytes long.
 Data: <Pragma:  > 50 72 61 67 6D 61 3A 20 00 
{297799} normal block at 0x0000000007691060, 16 bytes long.
 Data: <  i             > 10 10 69 07 00 00 00 00 00 00 00 00 00 00 00 00 

I examined the program and found that when I delete this code m_Model = osgDB::readNodeFile(m_strModelName); there is no more memory leaks.

void COSGEarth::InitSceneGraph(void)
{
    // Init the main Root Node/Group
    m_Root = new osg::Group;
    // Load the Model from the model name, 
    //delete below line, no memory leak
    m_Model = osgDB::readNodeFile(m_strModelName);
    if (!m_Model) return;

    // Optimize the model
    osgUtil::Optimizer optimizer;
    optimizer.optimize(m_Model.get());
    optimizer.reset();

    // Add the model to the scene
    m_Root->addChild(m_Model.get());

}

I defined m_Model as osg::ref_ptr<osg::Node> m_Model. This is Intelligent pointer.

Why there are memory leaks and how I can solve this issue?

Here is source code :http://bbs.osgchina.org/forum.php?mod=attachment&aid=NzIwNnwzZWYxZDIyZjlhOGY1MWFjZjhiNGFiMWYwMTc5YmJlNXwxNTEyMzc5ODE2&request=yes&_f=.zip

1

There are 1 answers

1
XenonofArcticus On

I believe these reported "leaks" are false positives. Refer to this thread that explains why:

http://forum.openscenegraph.org/viewtopic.php?t=1475