# HG changeset patch # User dsimms # Date 1408006594 -7200 # Node ID 8ae0d26ab728b9df3ed1bbe73ab4908e4414db49 # Parent 5c8178d7dd3525cb7bacfc496adc58c2bd1da43d 8046919: jni_PushLocalFrame OOM - increase MAX_REASONABLE_LOCAL_CAPACITY Summary: Increase the previous limit from 4k to 64k, added "-XX:MaxJNILocalCapacity=" flag Reviewed-by: hseigel, fparain diff -r 5c8178d7dd35 -r 8ae0d26ab728 src/share/vm/prims/jni.cpp --- a/src/share/vm/prims/jni.cpp Thu Aug 14 12:58:56 2014 -0700 +++ b/src/share/vm/prims/jni.cpp Thu Aug 14 10:56:34 2014 +0200 @@ -292,15 +292,6 @@ "Bug in native code: jfieldID offset must address interior of object"); } -// Pick a reasonable higher bound for local capacity requested -// for EnsureLocalCapacity and PushLocalFrame. We don't want it too -// high because a test (or very unusual application) may try to allocate -// that many handles and run out of swap space. An implementation is -// permitted to allocate more handles than the ensured capacity, so this -// value is set high enough to prevent compatibility problems. -const int MAX_REASONABLE_LOCAL_CAPACITY = 4*K; - - // Wrapper to trace JNI functions #ifdef ASSERT @@ -880,7 +871,8 @@ env, capacity); #endif /* USDT2 */ //%note jni_11 - if (capacity < 0 || capacity > MAX_REASONABLE_LOCAL_CAPACITY) { + if (capacity < 0 || + ((MaxJNILocalCapacity > 0) && (capacity > MaxJNILocalCapacity))) { #ifndef USDT2 DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, JNI_ERR); #else /* USDT2 */ @@ -1039,7 +1031,8 @@ env, capacity); #endif /* USDT2 */ jint ret; - if (capacity >= 0 && capacity <= MAX_REASONABLE_LOCAL_CAPACITY) { + if (capacity >= 0 && + ((MaxJNILocalCapacity <= 0) || (capacity <= MaxJNILocalCapacity))) { ret = JNI_OK; } else { ret = JNI_ERR; diff -r 5c8178d7dd35 -r 8ae0d26ab728 src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Thu Aug 14 12:58:56 2014 -0700 +++ b/src/share/vm/runtime/globals.hpp Thu Aug 14 10:56:34 2014 +0200 @@ -1216,6 +1216,11 @@ product(bool, UseFastJNIAccessors, true, \ "Use optimized versions of GetField") \ \ + product(intx, MaxJNILocalCapacity, 65536, \ + "Maximum allowable local JNI handle capacity to " \ + "EnsureLocalCapacity() and PushLocalFrame(), " \ + "where <= 0 is unlimited, default: 65536") \ + \ product(bool, EagerXrunInit, false, \ "Eagerly initialize -Xrun libraries; allows startup profiling, " \ "but not all -Xrun libraries may support the state of the VM " \