<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
VTK deletes an object when the reference count of the object becomes zero.&nbsp; At this point, the OS is free to reclaim the memory and write to the memory chunk once occupied by the object.&nbsp; Your debug, however, does not know this and try to deciper the chunk of memory pointed by the pointer variable.&nbsp; Hence the&nbsp;meaningless values.&nbsp; The heap profiler probably avoids immediate reuse of the memory, hence leaving the reference count value etc. intact.<br><br>Xiaofeng Zhao<br>
<br>&nbsp;<BR><div><hr id="stopSpelling">Date: Wed, 6 Jul 2011 17:34:51 -0400<br>Subject: Re: [vtkusers] Delete actor and release memory<br>From: nicolas.lists@gmail.com<br>To: drescherjm@gmail.com<br>CC: xf10036@hotmail.com; vtkusers@public.kitware.com<br><br><br><br><div class="ecxgmail_quote">On Wed, Jul 6, 2011 at 4:06 PM, John Drescher <span dir="ltr">&lt;<a href="mailto:drescherjm@gmail.com">drescherjm@gmail.com</a>&gt;</span> wrote:<br><blockquote style="padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" class="ecxgmail_quote">
<div class="ecxim">On Wed, Jul 6, 2011 at 3:56 PM, Nicolas Rannou &lt;<a href="mailto:nicolas.lists@gmail.com">nicolas.lists@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Wed, Jul 6, 2011 at 3:43 PM, John Drescher &lt;<a href="mailto:drescherjm@gmail.com">drescherjm@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Jul 6, 2011 at 10:35 AM, Xiaofeng Z &lt;<a href="mailto:xf10036@hotmail.com">xf10036@hotmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt; That's interesting, and quite unintuitive! maybe someone with better<br>
&gt;&gt; &gt; understanding of VTK's inner work can offer an explanation!<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; To me this looks like garbage being left over after the object was<br>
&gt;&gt; deleted. You need to look at the reference counts before the delete<br>
&gt;&gt; not after.<br>
&gt;&gt;<br>
&gt;&gt; John<br>
&gt;<br>
&gt; How could I avoid garbage being left over?<br>
<br>
</div>What I mean is after the Delete if the object was really deleted the<br>
reference counts could be not trusted because the memory holding the<br>
reference counts would be freed. I would trace through the code to see<br>
what exactly is happening.<br>
<font color="#888888"><br>
John<br>
</font></blockquote></div><br><div><span style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse;" class="ecxApple-style-span"><div>
Ok I see what you mean now.</div><div><br></div><div>I'll try to debug it step by step and see what is&nbsp;happening...</div><div><br></div><div>I used to rely on the system monitor to get a gross approximation of the memory usage but it looks like it is quite not reliable.</div>
<div><br></div><div>I debugged my program with massif (<a style="color: rgb(0, 0, 0);" href="http://valgrind.org/docs/manual/ms-manual.html" target="_blank">http://valgrind.org/docs/manual/ms-manual.html</a>) and the memory usage looks fine.</div>
<div>(the memory usage decreases significantly after deleting actors, mappers and polydatas)</div><div><br></div><div>A surprising thing is that, if I run my program with this heap profiler tool, the ref counts of the polydatas, mappers and actors are "accurate" (==0) after deleting the objects. The same program without the heap profiler returns weird ref counts after deleting the objects.</div>
<div><br></div><div>I'm wondering if the memory usage looks fine into massif because the ref counts are corrects (==0) or if the system monitor is just wrong and the ref counts don't really matter.</div><div>In other words, if I get ref counts == 0 in my program (without heap profiler), would I be able to see the memory usage decrease in the system monitor?</div>
<div><br></div><div>Thanks</div></span></div></div>                                               </div></body>
</html>