This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Will garbage collector run on the spot Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Will garbage collector run on the spot" Watch "Will garbage collector run on the spot" New topic
Author

Will garbage collector run on the spot

Dinesh Tahiliani
Ranch Hand

Joined: Aug 06, 2007
Posts: 486
Hello

When i call Runtime.getRuntime() and System.gc() method, will garbage collector run on the spot and free the memory space . Or JVM will decide to run the garbage collector.


Thanks<br />Dinesh
cchetan jain
Ranch Hand

Joined: Jul 05, 2009
Posts: 30
you can not force to run the garbage collector..when you apply a method to run ..it depends on the jvm that it will allow the garbage collector to run or not instanty...
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

Dinesh Tahiliani wrote:Hello

When i call Runtime.getRuntime() and System.gc() method, will garbage collector run on the spot and free the memory space . Or JVM will decide to run the garbage collector.


if you call Runtime.getRuntime() you say nothing to JVM
you have to use:
Runtime.getRuntime().gc();


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
 
Don't get me started about those stupid light bulbs.
 
subject: Will garbage collector run on the spot