Saturday, March 12, 2016

Java Examples : How To Get Free Memory Of JVM (Java Virtual Machine)

Intro


This tutorials, will show how to get free memory of JVM. To get free memory of JVM, you should use the Runtime class.

Examples


package com.freesamplecode.java.basic;

public class GetFreeMemoryJVMDemo {
	public static void main(String[] args){
		Runtime runtime = Runtime.getRuntime();
		
		long freeMemory = runtime.freeMemory();
		
		System.out.println("Free memory in JVM is : "+freeMemory +" byte");
	}
}

Output


Free memory in JVM is : 121587520 byte


Screenshot

How To Get Free Memory Of JVM (Java Virtual Machine)

Related Posts:

0 comments: