False memory leak reports are caused by VTK dlls loading *before* MFC
dlls. You have to use the linker's /delayload flag to avoid this issue.<br><br>
The /delayload flag should be correct by default in the MFC examples if
you are using CVS VTK... If you are using a previous version of VTK
(5.0 or earlier) then you will have to figure out a way to link with
that flag.<br>
<br>
See the CVS version of files in VTK/GUISupport/MFC for details. Or grep the VTK source tree for "DELAYLOAD"<br>
<br>
HTH,<br>
David<br>
<br><div><span class="gmail_quote">On 5/10/07, <b class="gmail_sendername">Marcus Wilkinson</b> <<a href="mailto:wilkinsonmarcus@gmail.com">wilkinsonmarcus@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
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><span class="sg"><br>Marcus<br>
</span><br>_______________________________________________<br>This is the private VTK discussion list.<br>Please keep messages on-topic. Check the FAQ at: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>Follow this link to subscribe/unsubscribe:<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers
</a><br><br></blockquote></div><br>