This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage Collection" Watch "Garbage Collection" New topic

Garbage Collection

J. Scott Smith

Joined: Mar 08, 2000
Posts: 5
Can garbage collection ensure that a program will not run out of memory while running?
I know there is no way to know when it will begin, but does it have a safegaurd that will cause it to execute at some random time before the program runs out of memory?

Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
In fact, it is guaranteed that it will run immediately if a memory request is made and insufficient memory is present to fill the request. However, there is no guarantee that it will be able to successfully free any memory - if all the objects in memory still have references to them, you're basically screwed.

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: Garbage Collection
It's not a secret anymore!