mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-31 05:05:32 +00:00
8207139: NMT is not enabled on Windows 2016/10
Reviewed-by: dcubed, zgu, dholmes
This commit is contained in:
parent
b6532bdf48
commit
e8dd517464
@ -35,6 +35,10 @@
|
||||
#include "utilities/defaultStream.hpp"
|
||||
#include "utilities/vmError.hpp"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef SOLARIS
|
||||
volatile bool NMT_stack_walkable = false;
|
||||
#else
|
||||
@ -48,24 +52,31 @@ MemBaseline MemTracker::_baseline;
|
||||
Mutex* MemTracker::_query_lock = NULL;
|
||||
bool MemTracker::_is_nmt_env_valid = true;
|
||||
|
||||
static const size_t buffer_size = 64;
|
||||
|
||||
NMT_TrackingLevel MemTracker::init_tracking_level() {
|
||||
char nmt_env_variable[buffer_size];
|
||||
jio_snprintf(nmt_env_variable, sizeof(nmt_env_variable), "NMT_LEVEL_%d", os::current_process_id());
|
||||
const char* nmt_env_value;
|
||||
#ifdef _WINDOWS
|
||||
// Read the NMT environment variable from the PEB instead of the CRT
|
||||
char value[buffer_size];
|
||||
nmt_env_value = GetEnvironmentVariable(nmt_env_variable, value, (DWORD)sizeof(value)) != 0 ? value : NULL;
|
||||
#else
|
||||
nmt_env_value = ::getenv(nmt_env_variable);
|
||||
#endif
|
||||
NMT_TrackingLevel level = NMT_off;
|
||||
char buf[64];
|
||||
jio_snprintf(buf, sizeof(buf), "NMT_LEVEL_%d", os::current_process_id());
|
||||
const char *nmt_option = ::getenv(buf);
|
||||
if (nmt_option != NULL) {
|
||||
if (strcmp(nmt_option, "summary") == 0) {
|
||||
if (nmt_env_value != NULL) {
|
||||
if (strcmp(nmt_env_value, "summary") == 0) {
|
||||
level = NMT_summary;
|
||||
} else if (strcmp(nmt_option, "detail") == 0) {
|
||||
} else if (strcmp(nmt_env_value, "detail") == 0) {
|
||||
level = NMT_detail;
|
||||
} else if (strcmp(nmt_option, "off") != 0) {
|
||||
// The option value is invalid
|
||||
} else if (strcmp(nmt_env_value, "off") != 0) {
|
||||
// The value of the environment variable is invalid
|
||||
_is_nmt_env_valid = false;
|
||||
}
|
||||
|
||||
// Remove the environment variable to avoid leaking to child processes
|
||||
os::unsetenv(buf);
|
||||
os::unsetenv(nmt_env_variable);
|
||||
}
|
||||
|
||||
// Construct NativeCallStack::EMPTY_STACK. It may get constructed twice,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user