Hi All,<br><br>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.<br>I have 2 DLL's, one containing my main sound analysis program and another holding VTK code for visualisation.
<br>Sound.dll loads Visualisation.dll via a call to LoadLibrary("Vlisualisation.dll");<br><br>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.
<br><br>This CVisualisationApp class is instantiated by one of the static functions {"CreateSystem()"} which just does:<br>theApp = new CVisualisationApp();<br><br>so basically, by Visualisation.h looks something like this:
<br><br style="color: rgb(0, 0, 102);"><div style="margin-left: 40px;"><font style="color: rgb(0, 0, 102);" size="1">class CVisualisationApp : public CWinApp</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1">
{</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1">public:</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1"> CVisualisationApp();</font><br style="color: rgb(0, 0, 102);">
<font style="color: rgb(0, 0, 102);" size="1"> ~CVisualisationApp();</font><br style="color: rgb(0, 0, 102);"><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1">public:</font><br style="color: rgb(0, 0, 102);">
<font style="color: rgb(0, 0, 102);" size="1"> virtual BOOL InitInstance();</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1"></font><font style="color: rgb(0, 0, 102);" size="1"> BOOL Render(double dt);
</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1"> //more functions and fun</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1">}</font><br></div>
<br>and my Visualisation.cpp looks a bit like this:<br><br style="color: rgb(51, 0, 153);"><div style="margin-left: 40px;"><font style="color: rgb(0, 0, 102);" size="1">CVisualisationApp *theApp = 0;</font><br style="color: rgb(0, 0, 102);">
<br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1">extern "C" __declspec( dllexport )</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1">int __cdecl createSystem() {
</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1"> </font><font style="color: rgb(0, 0, 102);" size="1">if (theApp != 0)</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1">
return 0;</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1"> theApp = new CVisualisationApp();</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1">
theApp->InitInstance();</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1"> return 1;</font><br style="color: rgb(0, 0, 102);"><font size="1"><span style="color: rgb(0, 0, 102);">
}</span><br style="color: rgb(0, 0, 102);"><br style="color: rgb(0, 0, 102);"><span style="color: rgb(0, 0, 102);">CVisualisationApp::CVisualisationApp()</span><span style="color: rgb(0, 0, 102);"></span><br style="color: rgb(0, 0, 102);">
<span style="color: rgb(0, 0, 102);">{<br> //Instantiation stuff<br style="color: rgb(0, 0, 102);"></span><span style="color: rgb(0, 0, 102);">}<br><br></span></font><font size="1"><span style="color: rgb(0, 0, 102);">CVisualisationApp::InitInstance()
</span><span style="color: rgb(0, 0, 102);"></span><br style="color: rgb(0, 0, 102);">
<span style="color: rgb(0, 0, 102);">{<br>
//Initialisation stuff<br style="color: rgb(0, 0, 102);">
</span><span style="color: rgb(0, 0, 102);">}</span><br>
</font><br><font size="1"><span style="color: rgb(0, 0, 102);"></span><br></font></div><font size="2">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:
</font><br><br><br><div style="margin-left: 40px;"><font size="1">Detected memory leaks!</font><br><font size="1">Dumping objects -></font><br><font size="1">{32407} normal block at 0x0B70B070, 4 bytes long.</font><br>
<font size="1"> Data: <PWh > 50 57 68 0B </font><br><font size="1">{32406} normal block at 0x0C996730, 8 bytes long.</font><br><font size="1"> Data: <@f > 40 66 99 0C 00 00 00 00 </font><br><font size="1">
{32405} normal block at 0x0C997A38, 21 bytes long.</font><br><font size="1"> Data: <System Shutting > 53 79 73 74 65 6D 20 53 68 75 74 74 69 6E 67 20 </font><br><font size="1">{32404} normal block at 0x0C997980, 120 bytes long.
</font><br><font size="1"> Data: <\ p # > 5C 9F 70 0A 01 00 00 00 00 CD CD CD 23 03 02 00 </font><br><font size="1">{32368} normal block at 0x0C9971D8, 168 bytes long.</font><br><font size="1"> Data: < > CC B9 8F 09 01 00 00 00 00 CD CD CD 17 03 02 00
</font><br><font size="1">{32367} normal block at 0x0C9970F0, 168 bytes long.</font><br><font size="1"> Data: < > CC B9 8F 09 01 00 00 00 00 CD CD CD 15 03 02 00 </font><br><font size="1">{32366} normal block at 0x0C997008, 168 bytes long.
</font><br><font size="1"> Data: < 6 > CC B9 8F 09 02 00 00 00 00 CD CD CD 36 03 02 00 </font><br><font size="1">{32365} normal block at 0x0C996640, 176 bytes long.</font><br><font size="1"> Data: < 2r ( > A4 32 72 0A 01 00 00 00 00 CD CD CD 28 03 02 00
</font><br><font size="1">{32364} normal block at 0x0C996588, 120 bytes long</font><br><font size="1">{{{ Pages and pages more }}}</font><br></div><br><br>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.
<br><br>Marcus<br>