[vtkusers] Cleanup and Delete()
Matt Valerio
m-valerio at onu.edu
Thu Jul 22 09:13:48 EDT 2004
Hello,
I noticed in the examples that every VTK object created is ->Delete()ed
at the end of its use. I know it is good programming practice to clean
up memory, but is this necessary if all your ->Delete() calls come at
the end of main() right before the return(EXIT_SUCESS); part? I assume
that the memory occupied by these objects is automatically freed when
the application terminates?
The reason I'm asking this is because I have a sample of code at the end
of my program that looks like this:
<code>
// And clean up
coneSource->Delete();
coneMapper->Delete();
coneActor->Delete();
coneProperty->Delete();
sphereSource->Delete();
sphereMapper->Delete();
sphereActor->Delete();
sphereProperty->Delete();
ren1->Delete();
ren2->Delete();
renWin->Delete(); // Get errors when this line is uncommented
iren->Delete(); // Get errors when this line is uncommented
</code>
When I click the close button on the vtkRenderWindow, my application,
called vtktest4, shows these errors, only when the last 2 lines are
uncommented.
<error>
51 [main] vtktest4 1376 handle_exceptions: Exception:
STATUS_ACCESS_VIOLATION
4646 [main] vtktest4 1376 open_stackdumpfile: Dumping stack trace to
vtktest4.exe.stackdump
</error>
Any ideas why this is happening? Am I ->Delete()ing the objects in the
wrong order?
I am running VTK 4.2 Latest Release under Cygwin on Windows 2000 (using
the Eclipse IDE).
Thanks!
Matt
More information about the vtkusers
mailing list