
top.hmtools.system.RuntimeInfoTools Maven / Gradle / Ivy
package top.hmtools.system;
/**
* 获取当前运行时信息工具类
* @author HyboJ
*
*/
public class RuntimeInfoTools {
private static Runtime currentRuntime = Runtime.getRuntime();
/**
* 获得运行时对象
* @return {@link Runtime}
*/
public static Runtime getRuntime(){
return currentRuntime;
}
/**
* 获得JVM最大可用内存
* @return 最大可用内存
*/
public static long getMaxMemory(){
return currentRuntime.maxMemory();
}
/**
* 获得JVM已分配内存
* @return 已分配内存
*/
public static long getTotalMemory(){
return currentRuntime.totalMemory();
}
/**
* 获得JVM已分配内存中的剩余空间
* @return 已分配内存中的剩余空间
*/
public static long getFreeMemory(){
return currentRuntime.freeMemory();
}
/**
* 获得JVM最大可用内存
* @return 最大可用内存
*/
public static long getUsableMemory(){
return currentRuntime.maxMemory() - currentRuntime.totalMemory() + currentRuntime.freeMemory();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy