File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Will garbage collector run on the spot