Skip to main content



      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 04:35
Eclipse UserFriend
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: Mon Jul 07 14:57:29 EDT 2025

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

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

Back to the top