public class MemoriaRAM {
private static com.sun.management.OperatingSystemMXBean mxbean;
static {
mxbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
}
public String getStringRAM(){
String ram = getMemoriaLivreBytes() + "#";
ram += getMemoriaLivreKBytes() + "#";
ram += getMemoriaLivreMBytes() + "#";
ram += getMemoriaLivreGBytes();
return ram;
}
public static long getMemoriaTotalBytes(){
return mxbean.getTotalPhysicalMemorySize();
}
public static long getMemoriaTotalKBytes(){
return mxbean.getTotalPhysicalMemorySize()/1024;
}
public static long getMemoriaTotalMBytes(){
return Math.round(mxbean.getTotalPhysicalMemorySize()/1024/1024);
}
public static long getMemoriaTotalGBytes(){
return Math.round(mxbean.getTotalPhysicalMemorySize()/1024/1024/1024);
}
public static long getMemoriaLivreBytes(){
return mxbean.getFreePhysicalMemorySize();
}
public static long getMemoriaLivreKBytes(){
return mxbean.getFreePhysicalMemorySize()/1024;
}
public static long getMemoriaLivreMBytes(){
return mxbean.getFreePhysicalMemorySize()/1024/1024;
}
public static long getMemoriaLivreGBytes(){
return mxbean.getFreePhysicalMemorySize()/1024/1024/1024;
}
public static OperatingSystemMXBean getMxbean() {
return mxbean;
}
}
Nenhum comentário:
Postar um comentário