In this core java tutorial we will Find Free Memory Available In JVM (Java virtual machine) In your System in java.
About freeMemory() method of java.lang.Runtime class in java >
- freeMemory() method of Runtime class returns the total amount of free memory in the JVM (Java virtual machine).
- freeMemory() is the native method in java.
finalize method in java - 13 salient features
Example/program to Find Free Memory Available In JVM (Java virtual machine) In your System >
/**
* Example/program to Find Free Memory Available In
* JVM (Java virtual machine) In your System
*/
public class FreeMemoryAvailableInJavaVirtualMachineExample{
public static void main(String[] args) {
/**
* first we will get the java Runtime object using the
* Runtime class's getRuntime() method in java.
*/
Runtime runtime = Runtime.getRuntime();
/**
* freeMemory() method of Runtime class returns the total
* amount of free memory in the JVM (Java virtual machine).
*
* freeMemory() is the native method.
*
* increasing free memory in java.
*/
long freeMemoryAvailableInJVM = runtime.freeMemory();
System.out.println("Total amount of free memory available in the "
+ "JVM (Java virtual machine) in bytes = "+ freeMemoryAvailableInJVM);
}
}
/* output
Total amount of free memory available in the JVM (Java virtual machine) in bytes = 253398664
*/
|
Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.
SUMMARY >
So in this core java tutorial we got the Free Memory Available In JVM (Java virtual machine) In your System in java.
RELATED LINKS>