[an error occurred while processing this directive]

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

                         

[an error occurred while processing this directive]