[vtkusers] Delete() usage
David E DeMarle
dave.demarle at kitware.com
Wed Oct 10 11:38:23 EDT 2012
Basic story is, anyone who needs long term access to an instance,
should Register to bump the reference count. This ensures that the
instance won't be destroyed until the last user is done with it.
Likewise when you are done using an object you call Delete so that it
will eventually be destroyed,.
New, Set and Register bump the reference count. (Set decrements the
old instances count too when you replace something).
Get does not change the reference count.
Make* or Create* methods (the name is not entirely standardized) do..
Delete and UnRegister decrement the count, and when the count reaches
0, delete is called.
SmartPointers do the New for you, and call Delete when the
SmartPointer goes out of scope.
See this email for more clarification:
http://markmail.org/thread/glsnszxdkf323bhh
David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909
On Wed, Oct 10, 2012 at 10:55 AM, Jean-Hugues Royer <jhroyer at joher.com> wrote:
> Hi,
>
> Tracking memory leaks...
>
> As far as I read we are supposed to call the Delete() method each time we
> issue a New() object.
>
>
> Are we also supposed to call Delete() on objects we received from Get*()
> functions ?
>
> Example:
>
> vtkPolyData pd =
> vtkContourWidget.GetContourRepresentation().GetContourRepresentationAsPolyData()
>
> Do I have to call pd.Delete() to free it or will vtkContourWidget free it
> when deleted ?
>
>
> And regarding Set*() functions, example:
>
> vtkPlaneCollection pc = vtkPlaneCollection.New();
> vtkSmartVolumeMapper.SetClippingPlanes(pc);
>
> Do I have to call pd.Delete() to free the plane collection or will it be
> freed when the vtkSmartVolumeMapper will be deleted ?
>
>
> Thanks.
>
> _______________________________________________
> 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
More information about the vtkusers
mailing list