Share on Google+Share on Google+

Java Get Memory

Advertisement
In this section of Java Example, you will see how to get the memory size using Java programming language.

Java Get Memory

     

In this section of Java Example, you will see how to get the memory size using Java programming language. This is a very simple example and you can easily learn it.

In this Java Get Memory Size example, we have created a class called Memory and defined all the functionality in it to show the memory size. System.out.println is used to print the result on the command prompt.

Code to Get Memory Size in Java

public class Memory {

    public static void main(String[] args) {
 
       System.out.println("Total Memory"+Runtime.getRuntime().totalMemory());    
       System.out.println("Free Memory"+Runtime.getRuntime().freeMemory());
}
}

Output will be displayed as:

Download Source Code

Advertisements

Advertisement

Posted on: May 27, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

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.

Comments:1
lee jae bong
March 14, 2012
dd

thank you very much