8334489: Add function os::used_memory
Reviewed-by: eosterlund, dholmes, stuefe
This commit is contained in:
parent
edf7f055ee
commit
05a63d80b9
@ -78,6 +78,10 @@
|
|||||||
#include "utilities/macros.hpp"
|
#include "utilities/macros.hpp"
|
||||||
#include "utilities/powerOfTwo.hpp"
|
#include "utilities/powerOfTwo.hpp"
|
||||||
|
|
||||||
|
#ifdef LINUX
|
||||||
|
#include "osContainer_linux.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef _WINDOWS
|
#ifndef _WINDOWS
|
||||||
# include <poll.h>
|
# include <poll.h>
|
||||||
#endif
|
#endif
|
||||||
@ -2064,6 +2068,19 @@ static void assert_nonempty_range(const char* addr, size_t bytes) {
|
|||||||
p2i(addr), p2i(addr) + bytes);
|
p2i(addr), p2i(addr) + bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
julong os::used_memory() {
|
||||||
|
#ifdef LINUX
|
||||||
|
if (OSContainer::is_containerized()) {
|
||||||
|
jlong mem_usage = OSContainer::memory_usage_in_bytes();
|
||||||
|
if (mem_usage > 0) {
|
||||||
|
return mem_usage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return os::physical_memory() - os::available_memory();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool os::commit_memory(char* addr, size_t bytes, bool executable) {
|
bool os::commit_memory(char* addr, size_t bytes, bool executable) {
|
||||||
assert_nonempty_range(addr, bytes);
|
assert_nonempty_range(addr, bytes);
|
||||||
bool res = pd_commit_memory(addr, bytes, executable);
|
bool res = pd_commit_memory(addr, bytes, executable);
|
||||||
|
@ -336,6 +336,7 @@ class os: AllStatic {
|
|||||||
// than "free" memory (`MemFree` in `/proc/meminfo`) because Linux can free memory
|
// than "free" memory (`MemFree` in `/proc/meminfo`) because Linux can free memory
|
||||||
// aggressively (e.g. clear caches) so that it becomes available.
|
// aggressively (e.g. clear caches) so that it becomes available.
|
||||||
static julong available_memory();
|
static julong available_memory();
|
||||||
|
static julong used_memory();
|
||||||
static julong free_memory();
|
static julong free_memory();
|
||||||
|
|
||||||
static jlong total_swap_space();
|
static jlong total_swap_space();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user