Home Java Java-get-example Java get Free Memory
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java get Free Memory

Advertisement
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

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 1, 2008

Ask Questions?    Discuss: Java get Free Memory  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
john
December 30, 2011
male

good
DMCA.com