/*
Get Free Memory of Java Virtual Machine(JVM) Example
This Java example shows how to get amount of free memory
in the Java Virtual Machine(JVM) using freeMemory method
of Java Runtime class.
*/
package org.best.example;
public class GetFreeMemory {
public static void main(String args[])
{
/*
* get current Java Runtime using getRuntime()
* method of Runtime class.
*/
Runtime runtime = Runtime.getRuntime();
/*
* To determine amount of free memory available to current
* Java Virtual Machine(JVM), use
*
* long freeMemory()
* method of Runtime class.
*/
long freeMemory = runtime.freeMemory();
System.out.println(freeMemory + " bytes free in JVM");
}
}
/*
Typical output would be
4993048 bytes free in JVM
*/
Get Free Memory of Java Virtual Machine(JVM) Example
This Java example shows how to get amount of free memory
in the Java Virtual Machine(JVM) using freeMemory method
of Java Runtime class.
*/
package org.best.example;
public class GetFreeMemory {
public static void main(String args[])
{
/*
* get current Java Runtime using getRuntime()
* method of Runtime class.
*/
Runtime runtime = Runtime.getRuntime();
/*
* To determine amount of free memory available to current
* Java Virtual Machine(JVM), use
*
* long freeMemory()
* method of Runtime class.
*/
long freeMemory = runtime.freeMemory();
System.out.println(freeMemory + " bytes free in JVM");
}
}
/*
Typical output would be
4993048 bytes free in JVM
*/
No comments:
Post a Comment