mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8299858: [Metrics] Swap memory limit reported incorrectly when too large
Reviewed-by: stuefe
This commit is contained in:
parent
28545dcf2b
commit
64ddf9536f
3 changed files with 67 additions and 3 deletions
|
@ -23,6 +23,7 @@
|
|||
* questions.
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
#include "jni.h"
|
||||
#include "jvm.h"
|
||||
|
@ -43,3 +44,15 @@ Java_jdk_internal_platform_CgroupMetrics_getTotalMemorySize0
|
|||
jlong page_size = sysconf(_SC_PAGESIZE);
|
||||
return pages * page_size;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_jdk_internal_platform_CgroupMetrics_getTotalSwapSize0
|
||||
(JNIEnv *env, jclass ignored)
|
||||
{
|
||||
struct sysinfo si;
|
||||
int retval = sysinfo(&si);
|
||||
if (retval < 0) {
|
||||
return 0; // syinfo failed, treat as no swap
|
||||
}
|
||||
return (jlong)si.totalswap;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue