Monday, 30 January 2017

Java Tutorial: Java Runtime class (gc method)


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=AHhIMs3HAyI&list=UUhwKlOVR041tngjerWxVccw

RuntimeDemo.java
import java.io.IOException;

public class RuntimeDemo
{

    public static void main(String[] args) throws IOException
    {
        /*
         * Returns the runtime object associated with the
         * current Java application.
         */
        Runtime runtime = Runtime.getRuntime();

        System.out.println("Runs the Gargage collector..");
        /*
         * Runs the garbage collector.
         * 
         * Calling this method suggests 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 virtual
         * machine has made its best effort to recycle all
         * discarded objects.
         * 
         * The name gc stands for "garbage collector". The
         * virtual machine performs this recycling process
         * automatically as needed, in a separate thread,
         * even if the gc method is not invoked explicitly.
         * 
         * The method System.gc() is the conventional and
         * convenient means of invoking this method.
         */
        runtime.gc();

    }

}
Output
Runs the Gargage collector..

Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/RuntimeDemo_GC_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/RuntimeDemo_GC_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/28b772df8f5b4b9e60fd873726243fc258cd34a2/BasicJava/RuntimeDemo_GC_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge