View Single Post
  #13 (permalink)  
Old 09-12-2008, 11:55 AM
fishtoprecords's Avatar
fishtoprecords fishtoprecords is offline
Senior Member
 
Join Date: Jun 2008
Posts: 522
fishtoprecords is on a distinguished road
Quote:
Originally Posted by Eranga View Post
Code:
delete[] temp;
what happen if I forget to delete the array.
What happens is, of course, that you get a nearly impossible to find memory leak. And you not only have to remember to write the code to do the delete, but you have to make sure that its executed on every path in your code, including any and all exceptions.

Don't forget to trap all exceptions that you never heard of, because some other developer changed code way down in the call tree in ways you never expected.

There are real engineering reasons why Java has garbage collection: it makes the computer do what programmers and other humans do poorly.

Back in the mid-1990s, folks had theological arguments that garbage collection was too slow. And it can be too slow for realtime work. So the solution is to not use Java for real time work.

The theological arguments ignored the cost and slowness of finding memory leaks in complex systems.
Reply With Quote