< prev index next >

src/hotspot/share/services/memTracker.cpp

Print this page
rev 50951 : imported patch static_initialization.patch


  51 
  52 NMT_TrackingLevel MemTracker::init_tracking_level() {
  53   NMT_TrackingLevel level = NMT_off;
  54   char buf[64];
  55   jio_snprintf(buf, sizeof(buf), "NMT_LEVEL_%d", os::current_process_id());
  56   const char *nmt_option = ::getenv(buf);
  57   if (nmt_option != NULL) {
  58     if (strcmp(nmt_option, "summary") == 0) {
  59       level = NMT_summary;
  60     } else if (strcmp(nmt_option, "detail") == 0) {
  61       level = NMT_detail;
  62     } else if (strcmp(nmt_option, "off") != 0) {
  63       // The option value is invalid
  64       _is_nmt_env_valid = false;
  65     }
  66 
  67     // Remove the environment variable to avoid leaking to child processes
  68     os::unsetenv(buf);
  69   }
  70 
  71   // Construct NativeCallStack::EMPTY_STACK. It may get constructed twice,
  72   // but it is benign, the results are the same.
  73   ::new ((void*)&NativeCallStack::EMPTY_STACK) NativeCallStack(0, false);
  74 
  75   if (!MallocTracker::initialize(level) ||
  76       !VirtualMemoryTracker::initialize(level)) {
  77     level = NMT_off;
  78   }
  79   return level;
  80 }
  81 
  82 void MemTracker::init() {
  83   NMT_TrackingLevel level = tracking_level();
  84   if (level >= NMT_summary) {
  85     if (!VirtualMemoryTracker::late_initialize(level)) {
  86       shutdown();
  87       return;
  88     }
  89     _query_lock = new (std::nothrow) Mutex(Monitor::max_nonleaf, "NMT_queryLock");
  90     // Already OOM. It is unlikely, but still have to handle it.
  91     if (_query_lock == NULL) {
  92       shutdown();
  93     }
  94   }




  51 
  52 NMT_TrackingLevel MemTracker::init_tracking_level() {
  53   NMT_TrackingLevel level = NMT_off;
  54   char buf[64];
  55   jio_snprintf(buf, sizeof(buf), "NMT_LEVEL_%d", os::current_process_id());
  56   const char *nmt_option = ::getenv(buf);
  57   if (nmt_option != NULL) {
  58     if (strcmp(nmt_option, "summary") == 0) {
  59       level = NMT_summary;
  60     } else if (strcmp(nmt_option, "detail") == 0) {
  61       level = NMT_detail;
  62     } else if (strcmp(nmt_option, "off") != 0) {
  63       // The option value is invalid
  64       _is_nmt_env_valid = false;
  65     }
  66 
  67     // Remove the environment variable to avoid leaking to child processes
  68     os::unsetenv(buf);
  69   }
  70 




  71   if (!MallocTracker::initialize(level) ||
  72       !VirtualMemoryTracker::initialize(level)) {
  73     level = NMT_off;
  74   }
  75   return level;
  76 }
  77 
  78 void MemTracker::init() {
  79   NMT_TrackingLevel level = tracking_level();
  80   if (level >= NMT_summary) {
  81     if (!VirtualMemoryTracker::late_initialize(level)) {
  82       shutdown();
  83       return;
  84     }
  85     _query_lock = new (std::nothrow) Mutex(Monitor::max_nonleaf, "NMT_queryLock");
  86     // Already OOM. It is unlikely, but still have to handle it.
  87     if (_query_lock == NULL) {
  88       shutdown();
  89     }
  90   }


< prev index next >