Home Java Java-get-example Java get Free Memory



Java get Free Memory
Posted on: November 1, 2008 at 12:00 AM
In this section, we are going to obtain the free memory. In order to get the memory left of being allocated, the method getruntime() returns the runtime object associated with the Java application.

Java get Free Memory

     

In this section, we are going to obtain the free memory. In order to get the memory left of being allocated, the method getruntime() returns the runtime object associated with the Java application.

freeMemory- This method returns the amount of free memory.

 

 

 

Here is the code of GetFreeMemory.java

public class GetFreeMemory
{
  public static void main(String[]args){
  long free = Runtime.getRuntime().freeMemory();
  System.out.println("Free Memory= "+free);
  }
}

Output will be displayed as:

Download Source Code

Related Tags for Java get Free Memory:
javacmemorytimeapplicationobjectioruntimefreemethodgetorderreturnthisssoaiappwithtoruncieitsectionociliimleftinasmnttrcalocatejemallallocamemolocmeobjppcatsurnsoeeatisimellgoarsocvaruntsruntsrdthavatiassociateapallocjeicaicaplono


More Tutorials from this section

Ask Questions?    Discuss: Java get Free Memory  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.