[vtkusers] Very important discovery\mistake !

Berk Geveci berk.geveci at kitware.com
Tue Jun 3 14:39:10 EDT 2003


Just for the record:

> Just for the record !
>
> Looks like the order to which "Delete"s are made has some importance !
> No need to play with "SetReferenceCount()" and stuff.
> Just deleting in the reverse order the instances were used (created)
> should destroy all  of them.

This is very wrong. The order in which the objects are deleted is
not relevant at all. The only possible leak in the example you sent
are due to the instance variables m_polydata and m_normal. Calling
SomeClass::CreateHexPolyData () more than once would cause leaks 
because you are not deleting these objects before assigning new values
to them. Otherwise, there is no leak. Please read the relevant
sections in the VTK documentation carefully before making assumptions
about how things work.

> In the past, I've forced sections of pipeline to delete by individually
> setting the inputs and output of *each* filter to NULL (i.e.
> disconnecting them all), and removing and other python references to
> them (no necessary for C++ presumably).

This is not the case in C++. There might be some issues due to Python's
garbage collection I am not aware of but you should not need to do
this in Python either.
 
> 
> As far as I know, a filter is only deleted if it has no connections to
> any other filters/objects. I'm not sure if VTK is smart enough to detect
> "isolated" sections of pipline for deletion.

This is not correct either. As long as the references to all objects
held by the application are released AND there are no circular
references introduced by the application, there should be no leaks.

-Berk







More information about the vtkusers mailing list