wxFormBuilder / ticpp

This project is obsolete. TinyXML-2 offers a very similar C++ interface.
MIT License
92 stars 34 forks source link

Memory leak #49

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
SVN revision 99

~TiCppRC() does not destroy correctly m_tiRC.

Here is the code

TiCppRC::~TiCppRC()
{   
    DeleteSpawnedWrappers();

    // Set pointer held by reference counter to NULL
    this->m_tiRC->Nullify();

    // Decrement reference - so reference counter will delete itself if necessary
    this->m_tiRC->DecRef();
}

The problem is TiCppRCImp(). Nullify() will put ref count to zero, then
DecRef() will decrement it once more, becoming negative, then test "if ( 0
== m_count )" will fail and object will never be destructed.

Simple solution is to replace == by >=

void TiCppRCImp::DecRef()
{
    --m_count;
    if ( 0 >= m_count )
    {
        delete m_tiCppRC;
        delete this;
    }
}

There seems to be another leak. Chasing it

Original issue reported on code.google.com by ndata...@gmail.com on 5 May 2009 at 1:29

GoogleCodeExporter commented 9 years ago
Ignore this non existing bug. I don't know what i was thinking.

Original comment by ndata...@gmail.com on 5 May 2009 at 1:38

GoogleCodeExporter commented 9 years ago
This solution actually solves a memory leak, that happens for unknown reason. It
maybe a side effect of another problem.

Some times m_tiRC->m_count is 0 when ~TiCppRC(). Nullify() is not the cause.

Original comment by ndata...@gmail.com on 5 May 2009 at 2:25

GoogleCodeExporter commented 9 years ago
So is this a bug? Or can I close this?

Original comment by rpusz...@gmail.com on 5 May 2009 at 9:32

GoogleCodeExporter commented 9 years ago
Close it please. There are memory leaks, but can't confirm that they come from 
ticpp,
probably from my code. 

Spent the entire day debugging. Only thing that i can say, it's  weird to have
reference count going negative. However, the way it's done, it does not cause 
double
delete of the same object, as i was expecting, unless "if ( 0 >= m_count )" is 
used.

Original comment by ndata...@gmail.com on 6 May 2009 at 7:49

GoogleCodeExporter commented 9 years ago

Original comment by rpusz...@gmail.com on 6 May 2009 at 12:37