Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Difference between System.gc() and Runtime.getRuntime().gc()
Difference between System.gc() and Runtime.getRuntime().gc() [message #710630] Fri, 05 August 2011 08:35
casperl90 is currently offline casperl90Friend
Messages: 5
Registered: August 2011
Junior Member
Q:-What is the Different between System.gc() and Runtime.getRuntime().gc()?


Answer-System.gc() runs the Garbage Collector.The JVM performs this recycling of all discarded obj's even if gc is not invoked explicitly.It is a static method.

Runtime.getRuntime() returns Runtime obj ass'ted wth the current java appl'n.
Once if we get the Runtime obj on that obj we can call one of the following methods
1)gc();
2)freeMemory();
3)totalMemory();
Most of the methods of Runtime class are instace methods.This is a static method.
Runtime class is a singleton class.we can create Runtime obj by using Factory method.

but System.gc() is equivalent to Runtime.getRuntime().gc()

and System.gc() is the most conventional and convenient method.
Previous Topic:Help needed
Next Topic:Undo history cleared on Save
Goto Forum:
  


Current Time: Thu Apr 25 06:59:35 GMT 2024

Powered by FUDForum. Page generated in 0.08840 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top