[vtkusers] vtkDebugLeaks is leaking memory?

Roland Schwarz roland.schwarz at chello.at
Sun Mar 10 06:21:28 EST 2002


I found two problems with vtkDebugLeaks:

1) It uses two global objects

static vtkSimpleCriticalSection DebugLeaksCritSec;

and

static vtkPrintLeaksAtExit vtkPrintLeaksAtExitGlobal;

but unfortunately they do not appear in this order in the source file. As a
result the critsec is beeing destroyed before printleaksatexit, which gives
reason for an access violation.
Perhaps this is compiler dependent, but my compiler documentations states:

construction order of global static objects is the same as they appear in
the source file. The destruction order is the exact reverse.

Simply reordering solves the problem, but is this compiler dependent?

2) vtkDebugLeaks does not free the memory allocated for the HashNodes. This
usually is not a problem, but when using together with an other framework
(such as MFC) the resulting leakage is reported there leaving the user
uncertain of the reason.
I fixed this by adding a destructor to vtkDebugLeaksHashTable:

vtkDebugLeaksHashTable::~vtkDebugLeaksHashTable()
{
  int i;
  for (i = 0; i < 64; i++)
    {
    if (NULL != this->Nodes[i]) delete this->Nodes[i];
    }
}

BTW.: Can anyone tell me the 'correct' and polite procedure to report
problems and/or bug fixes?

Thank you
Roland







More information about the vtkusers mailing list