[vtkusers] Problem with array not being deleted
Normand Mongeau
nmongeau at videotron.ca
Thu Oct 11 21:42:24 EDT 2007
OK, makes sense I guess. I'll try to read up on VTK's reference counting,
although I'm very familiar with the concept.
Thanks,
Normand
----- Original Message -----
From: "Berk Geveci" <berk.geveci at kitware.com>
To: "Normand Mongeau" <nmongeau at videotron.ca>
Cc: <vtkusers at vtk.org>
Sent: Thursday, October 11, 2007 7:33 PM
Subject: Re: [vtkusers] Problem with array not being deleted
> You have to call Delete() or UnRegister() on the charArray after
> adding it with SetScalars() otherwise it will leak. I recommend
> reading up on reference counting. I believe both of the VTK books have
> a section on it. Also, VTK's reference counting implementation is very
> similar to that of Objective C. Apple has several good documents on
> that.
>
> -berk
>
> On 10/11/07, Normand Mongeau <nmongeau at videotron.ca> wrote:
>>
>>
>> Hi,
>>
>> I have a problem in C++, that goes like this:
>>
>> vtkImageData *workingImage = vtkImageData::New();
>> workingImage->SetNumberOfScalarComponents( 1 );
>> entireData = (unsigned char*)malloc(someSize);
>> workingImage->SetScalarTypeToUnsignedChar();
>> vtkUnsignedCharArray *charArray = vtkUnsignedCharArray::New( );
>> charArray->SetNumberOfComponents( 1 );
>> charArray->SetArray( entireData, someSize, 0 ); // 0 means to delete
>> after
>> use
>> workingImage->GetPointData()->SetScalars( charArray );
>> workingImage->Delete();
>>
>>
>> The problem is that my malloc'ed array never gets deleted. In fact, the
>> vtkUnsignedCharArray itself never gets deleted.
>>
>> Is there a fix/workaround to this?
>>
>> Thanks,
>>
>> Normand
>> _______________________________________________
>> This is the private VTK discussion list.
>> Please keep messages on-topic. Check the 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