1.1 --- a/src/share/vm/memory/collectorPolicy.cpp Wed Mar 27 10:55:37 2013 +0100 1.2 +++ b/src/share/vm/memory/collectorPolicy.cpp Thu Mar 28 10:27:28 2013 +0100 1.3 @@ -532,7 +532,7 @@ 1.4 1.5 // Loop until the allocation is satisified, 1.6 // or unsatisfied after GC. 1.7 - for (int try_count = 1; /* return or throw */; try_count += 1) { 1.8 + for (int try_count = 1, gclocker_stalled_count = 0; /* return or throw */; try_count += 1) { 1.9 HandleMark hm; // discard any handles allocated in each iteration 1.10 1.11 // First allocation attempt is lock-free. 1.12 @@ -576,6 +576,10 @@ 1.13 } 1.14 } 1.15 1.16 + if (gclocker_stalled_count > GCLockerRetryAllocationCount) { 1.17 + return NULL; // we didn't get to do a GC and we didn't get any memory 1.18 + } 1.19 + 1.20 // If this thread is not in a jni critical section, we stall 1.21 // the requestor until the critical section has cleared and 1.22 // GC allowed. When the critical section clears, a GC is 1.23 @@ -587,6 +591,7 @@ 1.24 MutexUnlocker mul(Heap_lock); 1.25 // Wait for JNI critical section to be exited 1.26 GC_locker::stall_until_clear(); 1.27 + gclocker_stalled_count += 1; 1.28 continue; 1.29 } else { 1.30 if (CheckJNICalls) {