[vtkusers] Recreating a smart pointer object after deletion

David Gobbi david.gobbi at gmail.com
Tue Nov 23 12:53:42 EST 2010


On Tue, Nov 23, 2010 at 10:46 AM, David Doria <daviddoria at gmail.com> wrote:

>
> If I do this (which works fine (no crash)):
>
>  vtkSmartPointer<vtkFloatArray> distances =
>    vtkSmartPointer<vtkFloatArray>::New();
>  std::cout << distances->GetNumberOfComponents() << std::endl;
>
>   distances.TakeReference(vtkFloatArray::New());
>   std::cout << distances->GetNumberOfComponents() << std::endl;
>
> there is a leak, right? The first vtkFloatArray object is never
> deleted. How do you delete the memory allocated to the first object?
> (This is why I had tried calling Delete(), which you say should never
> be done (and I agree, as it causes a crash every time :) )
>

Are you sure there is a leak?  Why do you think the first FloatArray isn't
being deleted?  Show me the evidence!

  David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101123/8dcb3008/attachment.htm>


More information about the vtkusers mailing list