Home  |   STIU  |   WOW  |   SCJP  |   SCDJWS   |   JEE FAQ  |   About US  |  

FAQ
  Java FAQ
  JSP FAQ
  Servlet FAQ
 

Advertisement

XyzWs Java FAQ:
What are the differences between System.gc() and Runtime.gc()?


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend


Previous Next vertical dots separating previous/next from contents/index/pdf Contents
Advertisement
XyzWs Java FAQ: What are the differences between System.gc() and Runtime.gc()?

What are the differences between System.gc() and Runtime.gc()?


There is no difference between these two methods.

Both methods suggest that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects.

The System.gc() is a static method so it's a little bit more convenient to use. The call System.gc() is effectively equivalent to the call:

 Runtime.getRuntime().gc()

Previous Next vertical dots separating previous/next from contents/index/pdf Contents

Support  | Feedback  | Help