<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. At this point, the OS is free to reclaim the memory and write to the memory chunk once occupied by the object. Your debug, however, does not know this and try to deciper the chunk of memory pointed by the pointer variable. Hence the meaningless values. The heap profiler probably avoids immediate reuse of the memory, hence leaving the reference count value etc. intact.<br><br>Xiaofeng Zhao<br>
<br> <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"><<a href="mailto:drescherjm@gmail.com">drescherjm@gmail.com</a>></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 <<a href="mailto:nicolas.lists@gmail.com">nicolas.lists@gmail.com</a>> wrote:<br>
><br>
><br>
> On Wed, Jul 6, 2011 at 3:43 PM, John Drescher <<a href="mailto:drescherjm@gmail.com">drescherjm@gmail.com</a>> wrote:<br>
>><br>
>> On Wed, Jul 6, 2011 at 10:35 AM, Xiaofeng Z <<a href="mailto:xf10036@hotmail.com">xf10036@hotmail.com</a>> wrote:<br>
>> > That's interesting, and quite unintuitive! maybe someone with better<br>
>> > understanding of VTK's inner work can offer an explanation!<br>
>> ><br>
>><br>
>> To me this looks like garbage being left over after the object was<br>
>> deleted. You need to look at the reference counts before the delete<br>
>> not after.<br>
>><br>
>> John<br>
><br>
> 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 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>