False memory leak reports are caused by VTK dlls loading *before* MFC
dlls. You have to use the linker&#39;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 &quot;DELAYLOAD&quot;<br>
<br>
HTH,<br>
David<br>
<br><div><span class="gmail_quote">On 5/10/07, <b class="gmail_sendername">Marcus Wilkinson</b> &lt;<a href="mailto:wilkinsonmarcus@gmail.com">wilkinsonmarcus@gmail.com</a>&gt; 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&#39;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(&quot;Vlisualisation.dll&quot;);<br><br>Inside
Visualisation.dll, I have a class &quot;CVisualisationApp&quot;, which is
instantiated by static functions in the Visualisation.dll such as
&quot;CreateSystem(), DestroySystem() etc&quot;. 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 {&quot;CreateSystem()&quot;} 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">&nbsp;&nbsp;&nbsp; CVisualisationApp();</font><br style="color: rgb(0, 0, 102);">

<font style="color: rgb(0, 0, 102);" size="1">&nbsp;&nbsp;&nbsp; ~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">&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp; BOOL Render(double dt);
</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1">&nbsp;&nbsp; //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 &quot;C&quot; __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">&nbsp;&nbsp;&nbsp; </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">

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 0;</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1">&nbsp;&nbsp;&nbsp; theApp = new CVisualisationApp();</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1">

&nbsp;&nbsp;&nbsp; theApp-&gt;InitInstance();</font><br style="color: rgb(0, 0, 102);"><font style="color: rgb(0, 0, 102);" size="1">&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp; //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>
&nbsp;&nbsp; //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&#39;t create the &#39;theApp&#39; 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&#39;t think there are any leaks there) -
or, does vtk have some static functions that could be causing memory
leaks even though I don&#39;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 -&gt;</font><br><font size="1">{32407} normal block at 0x0B70B070, 4 bytes long.</font><br>

<font size="1">&nbsp;Data: &lt;PWh &gt; 50 57 68 0B </font><br><font size="1">{32406} normal block at 0x0C996730, 8 bytes long.</font><br><font size="1">&nbsp;Data: &lt;@f&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt; 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">&nbsp;Data: &lt;System Shutting &gt; 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">&nbsp;Data: &lt;\
p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp; &gt; 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">&nbsp;Data:
&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&gt; 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">&nbsp;Data:
&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&gt; 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">&nbsp;Data:
&lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
6&nbsp;&nbsp; &gt; 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">&nbsp;Data:
&lt; 2r&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&nbsp;&nbsp;
&gt; 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">{{{&nbsp; 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>