[vtkusers] Delete actor and release memory
Xiaofeng Z
xf10036 at hotmail.com
Wed Jul 6 10:35:23 EDT 2011
That's interesting, and quite unintuitive! maybe someone with better understanding of VTK's inner work can offer an explanation!
Xiaofeng
Date: Wed, 6 Jul 2011 10:25:55 -0400
Subject: Re: [vtkusers] Delete actor and release memory
From: nicolas.lists at gmail.com
To: xf10036 at hotmail.com
CC: sebastien.jourdain at kitware.com; vtkusers at public.kitware.com
Actor:create -> ref count == 1add to renderer -> ref count == 2remove from renderer -> ref count == 1
delete -> ref count == 1576215064, -304508392, etc.
PolyData:create -> ref count == 1add to mapper -> ref count == 3
add mapper to actor, add actor to renderer, render -> ref count == 5remove actor from renderer, delete actor -> ref count == 3delete -> ref count == 52101520, -304508392, etc.
Something interesting I noticed is that if I do the same, without using the renderer (adding/removing actors), the polydata ref count looks fine:
Actor:create -> ref count == 1delete -> ref count == 1576215064, -304508392, etc.
PolyData:create -> ref count == 1add to mapper -> ref count == 3
delete related actor -> ref count == 3
delete -> ref count == 0
I tried the vtk master and 5.6.1 tag from github.
Thanks
On Tue, Jul 5, 2011 at 6:28 PM, Xiaofeng Z <xf10036 at hotmail.com> wrote:
Does the memory location pointed by variable actor still contain a valid
object (e.g. reference count > 0) after actor->Delete()? If not,
then memory used by actor should have been released.
xz
From: Nicolas Rannou
Sent: Tuesday, July 05, 2011 9:10 AM
To: Sebastien Jourdain
Cc: vtkusers at public.kitware.com
Subject: Re: [vtkusers] Delete actor and release
memory
Hi
Sebastien,
Yes, I don't delete it on purpose.
I would like to keep the polydata in memory but delete everything else
which is related to the visualization in order to decrease the memory
usage!
Thanks
Nicolas
On Sat, Jul 2, 2011 at 11:19 PM, Sebastien Jourdain <sebastien.jourdain at kitware.com>
wrote:
You never deleted the sphere.
On Tue, Jun 28, 2011 at 5:56 PM, Nicolas Rannou <nicolas.lists at gmail.com>
wrote:
> Hi all,
> I would like to delete/remove actors from my
rendering window to free
> memory.
> The issue is that the memory
usage doesn't decrease after removing/deleting
> the actors.
>
From my understanding, both following pseudo-codes should use the same
>
amount of memory.
> But,
> The first one uses: 15 Mb for 1000
spheres:
> The second uses: 90 Mb for 1000 spheres:
> How should I
proceed in the 2nd case, to get back to the "original" memory
> usage
without actor?
> Thanks,
>
> Nicolas
>
______________________________
> 15 Mb
>
______________________________
> //Create a sphere
>
vtkSphereSource* sphere = new ...
>
______________________________
> 90 Mb
>
______________________________
> //Create sphere
>
vtkSphereSource* sphere = new ...
> // mapper
> vtkMapper* mapper
...
> mapper->SetInput( sphere->GetOutput() )
> //
actor
> vtkActor* actor...
> actor->SetMapper(mapper)
>
mapper->Delete()
> // Add and remove actor
>
renderer->AddActor(actor)
> renderer->RemoveActor(actor)
>
// Delete actor
> actor->Delete()
>
______________________________
>
______________________________
>
>
>
_______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware
open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
>
Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this
link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
_______________________________________________
Powered by
www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages
on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow
this link to
subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110706/b93eacd5/attachment.htm>
More information about the vtkusers
mailing list