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