changeset 4639:79c6a69a317e

8012241: NMT huge memory footprint, it usually leads to OOME Summary: Enforce memory limitation on NMT to prevent JVM OOM Reviewed-by: acorn, dcubed, minqi
author zgu
date Fri, 12 Jul 2013 16:51:50 -0400
parents df77331d0dcb
children 9cc209978fc0
files src/share/vm/services/memTracker.cpp
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/services/memTracker.cpp	Thu Jul 11 06:32:48 2013 -0700
+++ b/src/share/vm/services/memTracker.cpp	Fri Jul 12 16:51:50 2013 -0400
@@ -387,6 +387,7 @@
 #define SAFE_SEQUENCE_THRESHOLD    30
 #define HIGH_GENERATION_THRESHOLD  60
 #define MAX_RECORDER_THREAD_RATIO  30
+#define MAX_RECORDER_PER_THREAD    100
 
 void MemTracker::sync() {
   assert(_tracking_level > NMT_off, "NMT is not enabled");
@@ -439,8 +440,14 @@
       // means that worker thread is lagging behind in processing them.
       if (!AutoShutdownNMT) {
         _slowdown_calling_thread = (MemRecorder::_instance_count > MAX_RECORDER_THREAD_RATIO * _thread_count);
+      } else {
+        // If auto shutdown is on, enforce MAX_RECORDER_PER_THREAD threshold to prevent OOM
+        if (MemRecorder::_instance_count >= _thread_count * MAX_RECORDER_PER_THREAD) {
+          shutdown(NMT_out_of_memory);
+        }
       }
 
+
       // check _worker_thread with lock to avoid racing condition
       if (_worker_thread != NULL) {
         _worker_thread->at_sync_point(pending_recorders, instanceKlass::number_of_instance_classes());