[vtkusers] Cleanup and Delete()

tom fogal tfogal at apollo.sr.unh.edu
Thu Jul 22 10:27:38 EDT 2004


 <40FFBD8C.9010606 at onu.edu>Matt Valerio writes:
>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?

It should be. With modern operating systems you shouldn't have a
problem. Some operating systems do a very poor job in cleaning up the
heap after an application terminates, however. On such systems you
would probably end up with a memory leak.

>	renWin->Delete(); // Get errors when this line is uncommented
>	iren->Delete(); // Get errors when this line is 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 had a similar problem earlier this week. Turns out I was
->Delete()ing an object more than I should have been.
Make sure you're code has 1 corresponding ->Delete() for every ::New().

HTH,

-tom



More information about the vtkusers mailing list