changeset 6347:dc427574bc7a

8033405: metaspace/stressHierarchy/stressHierarchy005 hangs in atexit handler Summary: <ake sure we shut down NMT before the VM exits and do not track malloc/free when NMT is shutting down Reviewed-by: coleenp, zgu
author ctornqvi
date Thu, 24 Apr 2014 00:46:17 +0200
parents b663617962e8
children 3117c892d6a7
files src/os/windows/vm/os_windows.cpp src/share/vm/services/memTracker.cpp
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/windows/vm/os_windows.cpp	Fri Apr 18 10:55:41 2014 -0700
+++ b/src/os/windows/vm/os_windows.cpp	Thu Apr 24 00:46:17 2014 +0200
@@ -130,6 +130,13 @@
     case DLL_PROCESS_DETACH:
       if(ForceTimeHighResolution)
         timeEndPeriod(1L);
+
+      // Workaround for issue when a custom launcher doesn't call
+      // DestroyJavaVM and NMT is trying to track memory when free is
+      // called from a static destructor
+      if (MemTracker::is_on()) {
+          MemTracker::shutdown(MemTracker::NMT_normal);
+      }
       break;
     default:
       break;
--- a/src/share/vm/services/memTracker.cpp	Fri Apr 18 10:55:41 2014 -0700
+++ b/src/share/vm/services/memTracker.cpp	Thu Apr 24 00:46:17 2014 +0200
@@ -785,7 +785,7 @@
   MEMFLAGS flags, address pc) {
   assert(old_addr != NULL && new_addr != NULL, "Sanity check");
   assert(_op == Realloc || _op == NoOp, "Wrong call");
-  if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp) {
+  if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp && !MemTracker::shutdown_in_progress()) {
     assert(_seq > 0, "Need pre-reserve sequence number");
     if (_need_thread_critical_lock) {
       ThreadCritical tc;
@@ -811,7 +811,7 @@
   // OOM already?
   if (addr == NULL) return;
 
-  if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp) {
+  if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp && !MemTracker::shutdown_in_progress()) {
     bool pre_reserved_seq = (_seq != 0);
     address  pc = CALLER_CALLER_PC;
     MEMFLAGS orig_flags = flags;