--- old/src/share/vm/runtime/thread.cpp Fri Jul 13 14:55:28 2012 +++ new/src/share/vm/runtime/thread.cpp Fri Jul 13 14:55:26 2012 @@ -327,8 +327,19 @@ // Reclaim the objectmonitors from the omFreeList of the moribund thread. ObjectSynchronizer::omFlush (this) ; - MemTracker::record_virtual_memory_release((_stack_base - _stack_size), - _stack_size, this); + // stack_base() asserts stack base address, that ensures all threads call + // Thread::record_stack_base_and_size() method, which will create + // thread native stack records. + // With exception that "Thread" objects are created, but failed + // to start. In this case, the stack information is not recorded. + OSThread* os_thr = osthread(); + if (os_thr != NULL && os_thr->get_state() != ALLOCATED && + os_thr->get_state() != INITIALIZED) { + + address stack_base_addr = stack_base(); + MemTracker::record_virtual_memory_release((stack_base_addr - stack_size()), + stack_size(), this); + } // deallocate data structures delete resource_area(); --- old/src/share/vm/services/memTracker.cpp Fri Jul 13 14:55:34 2012 +++ new/src/share/vm/services/memTracker.cpp Fri Jul 13 14:55:33 2012 @@ -351,12 +351,6 @@ } if (thread != NULL) { -#ifdef ASSERT - // cause assertion on stack base. This ensures that threads call - // Thread::record_stack_base_and_size() method, which will create - // thread native stack records. - thread->stack_base(); -#endif // for a JavaThread, if it is running in native state, we need to transition it to // VM state, so it can stop at safepoint. JavaThread running in VM state does not // need lock to write records.