This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Garbage Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Garbage Collection" Watch "Garbage Collection" New topic
Author

Garbage Collection

vigneswar rao
Greenhorn

Joined: Feb 12, 2006
Posts: 14
hi friends,
I have a samll doubt..
Does garbage collection guarantee that a program will not run out of memory or not ?
if run i want saple code, give me brief explaination.


thank you,
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24059
    
  13

No, it doesn't guarantee that, as you can always write a program that uses more memory than is available; for example, the one line

int[][] matrix = new int[1000000][1000000];

will exhaust the memory of any 32-bit JVM.

What garbage collection does do is free you from the need to deliberately delete memory you're no longer using, as you have to do in languages like C and C++.


[Jess in Action][AskingGoodQuestions]
vigneswar rao
Greenhorn

Joined: Feb 12, 2006
Posts: 14
Thanks to

Ernest Friedman-Hill
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Garbage Collection
 
Similar Threads
Garbage Collection Problem
Garbage Collection - Boone's Mock Q
HOw to Force GC
some Qs from javahomepage???
GC questions