Perplexing GC Time Growth

steve goldman Steve.Goldman at Sun.COM
Wed Jan 9 14:00:25 UTC 2008


Jason Vasquez wrote:
> On Jan 8, 2008, at 16:40 , Steve Bohne wrote:
>> Jason Vasquez wrote:
>>> I peppered the native code with  DeleteLocalRef directives anywhere  
>>> a local reference was declared, and  the number of JNI local refs  
>>> now stays steady at 52-53 during full  load. (!)   The JNI  
>>> documentation seems to indicate that I shouldn't  need to do that  
>>> for these type of references, but in any case, that is  an extreme  
>>> difference.
>> Normally, local references should be deleted automatically when a  
>> native method returns to Java.  One explanation for this behavior  
>> might involve some thread sitting in a native method and generating  
>> local references for a very long/indefinite amount of time, without  
>> returning to Java. Is this a possibility?
> 
> These references are generated from a separate native thread calling  
> up into Java.  The access pattern is a bit dodgy (legacy code here,  
> folks :)):
> 
> void foo() {
> ...
>        //ctl is some other object with a jenv member
>        jobject job = ctl->jenv->CallStaticObjectMethod( ctl->fooCls,  
> ctl->getInstanceMid );
>        ctl->jenv->CallVoidMethod( job,
>                                   ctl->newEventMid,
>                                   fooId,
>                                   eventType,
>                                   state,
>                                   data );
>        ctl->jenv->DeleteLocalRef(job); //newly added
> ...
> }
> 
> For C++ objects that have jenv as a local member or variable, it seems  
> that the local refs are cleaned up normally.  In access patterns of  
> the sort listed above, 'job' doesn't seem to be deleted, even though  
> 'foo()' enters and exits quite quickly.

This call direction is the opposite of what Steve was refering to. Local 
references created while in  native are automatically deleted when 
returning to Java, they are not removed when returning from Java to 
native. So if you C++ code looks effectively like

  for (;; ) { foo(); }

you will in fact never free local references without the DeleteLocalRef.


-- 
Steve
_______________________________________________
hotspot-gc-use mailing list
hotspot-gc-use at openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use



More information about the hotspot-gc-dev mailing list