Java Runtime.gc()

Syntax

Runtime.gc() has the following syntax.

public void gc()

Example

In the following code shows how to use Runtime.gc() method.


public class Main {
/*from  w  ww  .j a  v a 2s  .  c  o m*/
   public static void main(String[] args) {


      Runtime.getRuntime().gc();
      System.out.println("Completed.");
   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable