Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Java-get-example Java get Free Memory

Related Tutorials


 
 

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

If you enjoyed this post then why not add us on Google+? Add us to your Circles



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

Related Tutorials

Discuss: Java get Free Memory  

Post your Comment


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

good
DMCA.com