[vtkusers] Memory mangement in vtk

Marco Nawijn nawijn at gmail.com
Mon Jun 17 05:00:15 EDT 2013


You can however make VTK a little more C++ 11-ish with simple helpers. For
example I use the following template to make construction of VTK objects a
little less verbose:

template <typename T>
vtkSmartPointer<T> make_shared_vtk()
{ // Helper to reduce boilerplate code for creating VTK objects
  return vtkSmartPointer<T>::New();
}

As an example, the code for creating a vtkImageData object is then:

auto image = make_shared_vtk<vtkImageData>()

Regards,

Marco





On Mon, Jun 17, 2013 at 2:03 AM, Berk Geveci <berk.geveci at kitware.com>wrote:

> No current plans. The major issue is the effort involved in migrating all
> of the VTK code base as well as all applications that use VTK. It would be
> significant. There are also some other, more technical, issues. We have
> developed useful tools that depend on VTK's reference counting over the
> years. One is the ability to detect and break cycles. The other is the
> ability to track leaks of reference counted objects. I am not sure what it
> would take to implement these over shared_ptr.
>
> -berk
>
>
> On Fri, Jun 14, 2013 at 1:21 PM, Nick Overdijk <nick at astrant.net> wrote:
>
>> Hey,
>>
>> Are there any plans to remove the reference counted stuff from vtk/itk
>> and replace them with the new C++11 shared_ptr/unique_ptr (or
>> boost::shared_ptr/unique_ptr)? And also standard new/delete instead of
>> ::New and ::Delete? Why are those there anyway? I'd like to learn more
>> about some of the design choices of VTK/ITK, perhaps there's some sort of
>> document on that as well?
>>
>> Thanks in advance,
>>
>> _______________________________________________
>> 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/20130617/f2222823/attachment.htm>


More information about the vtkusers mailing list