How to retrieve available RAM from Windows command line?

前端 未结 11 673
-上瘾入骨i
-上瘾入骨i 2020-12-23 09:44

Is there a command line utility within Windows or third-party program that can retrieve available RAM on a machine? (Since I don\'t believe this can be done in pure JAVA, si

11条回答
  •  生来不讨喜
    2020-12-23 10:44

    Here is a pure Java solution actually:

    public static long getFreePhysicalMemory()
    {
        com.sun.management.OperatingSystemMXBean bean =
                (com.sun.management.OperatingSystemMXBean)
                        java.lang.management.ManagementFactory.getOperatingSystemMXBean();
        return bean.getFreePhysicalMemorySize();
    }
    

提交回复
热议问题