[vtkusers] [advice needed] - c++ memory management

Michael Jackson mike.jackson at bluequartz.net
Fri Dec 18 09:47:09 EST 2009


"Registering" the object by using object->Register() will increment  
the reference count of the object. When object->Delete() is called the  
reference count is decremented. If the reference count goes to Zero  
ONLY then is the object actually deleted from memory.

   Don't get confused with the c++ 'delete' versus vtkObjectBase- 
 >Delete(); Only under certain conditions do they do the same thing.

  So in your code you can safely call data = reader->GetOutput(); data- 
 >Register(NULL); and then return data.

_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio

On Dec 18, 2009, at 6:20 AM, hampycalc wrote:

> Presumably incrementing the reference count of the object returned by
> reader->GetOutput() (assigned to data) is going to have no effect  
> when the
> reader->Delete() is called, so data->Register(NULL)




More information about the vtkusers mailing list