Hackerss.com

Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in
hackerss
hackerss

Posted on

Call garbage collector in Java

Call garbage collector - Java:


public class GarbageCollector {
   /**
   * This method call garbage collector.
   */   
   public void callGC() {
       //Call garbage collector
       System.gc();
   }

   /**
   * One Example
   */
   public static void main(String args[]) throws IOException {

      GarbageCollector garbageCollector= new GarbageCollector ();
      //Example
      garbageCollector.callGC();
      //Output
      System.out.println("Garbage collector called"); //Garbage collector called
   }
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)