[vtkusers] Why there is no need to delete a render window to prevent memory leak?

David Doria daviddoria at gmail.com
Thu Nov 15 15:44:16 EST 2012


On Thu, Nov 15, 2012 at 3:40 PM, cel02000 <cel02000 at yahoo.com> wrote:
>
> Dear All,
>
> I have explained the problem that I had in using a vtkRenderWindow in this
> link
> http://vtk.1045678.n5.nabble.com/Unhandled-exception-error-when-using-the-function-SetStereoType-td5717150.html.
> I don't know why I should not delete renWin1 to prevent memory leak. Could
> someone help me find the answer? Thanks.
>
> Best,
> Ahmad


That post didn't have very much information, but it looks like you are doing:

vtkRenderWindow* renWin1 = ui.qvtkWidget->GetRenderWindow();

which isn't actually allocating new memory, but just pointing to the
same memory that qvtkWidget's RenderWindow is pointing to. Since it
owns it, surely it is trying to delete it, so by you deleting it as
well you are causing a problem. Just don't call Delete() - it
shouldn't cause a leak.

David



More information about the vtkusers mailing list