mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8292541: [Metrics] Reported memory limit may exceed physical machine memory
Reviewed-by: stuefe, sgehwolf
This commit is contained in:
parent
c74b6d4552
commit
9a0d1e7ce8
3 changed files with 52 additions and 16 deletions
|
@ -121,7 +121,13 @@ public class CgroupMetrics implements Metrics {
|
|||
|
||||
@Override
|
||||
public long getMemoryLimit() {
|
||||
return subsystem.getMemoryLimit();
|
||||
long subsMem = subsystem.getMemoryLimit();
|
||||
// Catch the cgroup memory limit exceeding host physical memory.
|
||||
// Treat this as unlimited.
|
||||
if (subsMem >= getTotalMemorySize0()) {
|
||||
return CgroupSubsystem.LONG_RETVAL_UNLIMITED;
|
||||
}
|
||||
return subsMem;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -178,5 +184,6 @@ public class CgroupMetrics implements Metrics {
|
|||
}
|
||||
|
||||
private static native boolean isUseContainerSupport();
|
||||
private static native long getTotalMemorySize0();
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
#include <unistd.h>
|
||||
|
||||
#include "jni.h"
|
||||
#include "jvm.h"
|
||||
|
@ -33,3 +34,10 @@ Java_jdk_internal_platform_CgroupMetrics_isUseContainerSupport(JNIEnv *env, jcla
|
|||
{
|
||||
return JVM_IsUseContainerSupport();
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_jdk_internal_platform_CgroupMetrics_getTotalMemorySize0
|
||||
(JNIEnv *env, jclass ignored)
|
||||
{
|
||||
return sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue