Branko Čibej <br...@wandisco.com> writes:

> The more important part of this change was the addition of
> POP_AND_RETURN_NOTHING at the end of the function (that you don't
> quote), because that actually destroys ("pops") the current local JNI
> frame and cleans up any remaining local references within it. We were
> leaking a whole frame, not just the single object reference in the loop,
> and that was affecting other code that happened to be in proximity to
> the call sites of this function.

I have to relearn this JNI stuff every time I look at it.  The local
refs are cleaned up automatically on return from the native code because
the JVM wraps the native call in PushLocalFrame/PopLocalFrame.  We use
DeleteLocalRef to control the number of local refs during the native
call.

The problem in this case was a missing PopLocalFrame which I guess means
that the JVM is not tracking the stack depth to automatically pop any
frames pushed by the native code.  I think that means we may still have
a problem in this function with the bare returns:

>>>          if (JNIUtil::isJavaExceptionThrown())
>>>            return;

-- 
Philip Martin | Subversion Committer
WANdisco // *Non-Stop Data*

Reply via email to