fix: no longer check linux for free memory size.

This commit is contained in:
huanghongxun 2021-08-29 04:27:31 +08:00
parent c23b9511b8
commit 5a1ebe906d

View File

@ -135,15 +135,6 @@ public enum OperatingSystem {
com.sun.management.OperatingSystemMXBean sunBean =
(com.sun.management.OperatingSystemMXBean)
java.lang.management.ManagementFactory.getOperatingSystemMXBean();
if (CURRENT_OS == LINUX) {
// On Linux, real amount of memory that is free for using is "available" size of memory,
// which also includes size of memory for caching that can be make use of.
// But available size of memory cannot be obtained by OperatingSystemMXBean interface.
// So we simply disable reporting free physical memory size on Linux.
return Optional.of(new PhysicalMemoryStatus(sunBean.getTotalPhysicalMemorySize(), -1));
}
return Optional.of(new PhysicalMemoryStatus(sunBean.getTotalPhysicalMemorySize(), sunBean.getFreePhysicalMemorySize()));
}
return Optional.empty();