[vtkusers] Memory leak I cant understand: Detected memory leaks!Dumping Objects ->

Paul Tait - OPES Paul at opes.com.au
Thu May 10 20:20:19 EDT 2007


These are real memory leaks as can be seen by the CD value. This is put in
by the MS CRT memory management when memory is allocated. FD is used in
delete. You will need to turn DEBUG_LEAKS on in VTK to see if it VTK or your
code that is leaking. That said I've been using VTK and MFC for a few years
and ALL memory leaks have been my fault
 
Paul Tait


 
Hi All,

I have limited experience with VTK, but from what I know about memory
management, I should be getting no memory leaks at all in my application at
all.
I have 2 DLL's, one containing my main sound analysis program and another
holding VTK code for visualisation. 
Sound.dll loads Visualisation.dll via a call to
LoadLibrary("Vlisualisation.dll");

Inside Visualisation.dll, I have a class "CVisualisationApp", which is
instantiated by static functions in the Visualisation.dll such as
"CreateSystem(), DestroySystem() etc". These static functions are called
externally by Sound.dll. This CVisualisationApp class holds all references
to VTK objects and extends CWinApp - it also holds the render function and
handles all UI basically. There are no calls to VTK elements outside of this
class. 

This CVisualisationApp class is instantiated by one of the static functions
{"CreateSystem()"} which just does:
theApp = new CVisualisationApp();

so basically, by Visualisation.h looks something like this: 


class CVisualisationApp : public CWinApp
{
public:
    CVisualisationApp();
    ~CVisualisationApp();

public:
    virtual BOOL InitInstance();
    BOOL Render(double dt); 
   //more functions and fun
}


and my Visualisation.cpp looks a bit like this:


CVisualisationApp *theApp = 0;

extern "C" __declspec( dllexport )
int __cdecl createSystem() { 
    if (theApp != 0)
        return 0;
    theApp = new CVisualisationApp();
    theApp->InitInstance();
    return 1;
}

CVisualisationApp::CVisualisationApp()
{
   //Instantiation stuff
}

CVisualisationApp::InitInstance() 
{
   //Initialisation stuff
}



Now my problem is that even if I don't create the 'theApp' object (comment
out the body of the createSystem() function), I still get memory leaks from
VTK. I guess my question is, could VTK detect memory leaks from my main
sound.dll app (although I don't think there are any leaks there) - or, does
vtk have some static functions that could be causing memory leaks even
though I don't create any objects. The output dump looks something like
this: 



Detected memory leaks!
Dumping objects ->
{32407} normal block at 0x0B70B070, 4 bytes long.
 Data: <PWh > 50 57 68 0B 
{32406} normal block at 0x0C996730, 8 bytes long.
 Data: <@f      > 40 66 99 0C 00 00 00 00 
{32405} normal block at 0x0C997A38, 21 bytes long.
 Data: <System Shutting > 53 79 73 74 65 6D 20 53 68 75 74 74 69 6E 67 20 
{32404} normal block at 0x0C997980, 120 bytes long. 
 Data: <\ p         #   > 5C 9F 70 0A 01 00 00 00 00 CD CD CD 23 03 02 00 
{32368} normal block at 0x0C9971D8, 168 bytes long.
 Data: <                > CC B9 8F 09 01 00 00 00 00 CD CD CD 17 03 02 00 
{32367} normal block at 0x0C9970F0, 168 bytes long.
 Data: <                > CC B9 8F 09 01 00 00 00 00 CD CD CD 15 03 02 00 
{32366} normal block at 0x0C997008, 168 bytes long. 
 Data: <            6   > CC B9 8F 09 02 00 00 00 00 CD CD CD 36 03 02 00 
{32365} normal block at 0x0C996640, 176 bytes long.
 Data: < 2r         (   > A4 32 72 0A 01 00 00 00 00 CD CD CD 28 03 02 00 
{32364} normal block at 0x0C996588, 120 bytes long
{{{  Pages and pages more }}}



Thanks in advance for any thoughts you have - feel like my brain is melting
on this one. If you need, I can provide a list of libs and include files. 

Marcus


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070511/4eadbfeb/attachment.htm>


More information about the vtkusers mailing list