flier / jav8

An implementation of the Java Scripting API (JSR223) base on the Google V8 Javascript engine.
13 stars 4 forks source link

ReferenceTable overflow #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi i'am trying to use jav8 on android. After a few issues i was able to get it 
running on android.

Now I have one major issue. If I expose some java code to javascript, after 
many call to a java method from JavaScript (max is arround 500 calls) my app 
crash with a "ReferenceTable overflow"

I found that some ref wasn't deleted in Wrapper.cpp CJavaFunction::Caller (for 
exemple params var, and arguments passed to SetObjectArrayElement). After 
fixing it, I was able to make more call to java method, but I still get a 
ReferenceTable overflow.

I think there still a "leak" in Utils.cpp Cache::GetMember() when calling 
GetObjectClass()

members_t::iterator iter = CacheMembers(env->GetObjectClass(obj));

If i replace this with  : 

jclass foo = env->GetObjectClass(obj);
members_t::iterator iter = CacheMembers(foo);
env->DeleteLocalRef(foo);

I no longer have a ReferenceTable overflow but my code crash randomly. Any idea 
on how to fix this? 

The easiest way to reproduce this bug is :

1) Create a java class with a method and expose it to javascript
2) In your JavaScript code : 
for (var i = 0; i < 1024; i++) {
    //Call java method here
}
3) Wait for crash 

I'am using jav8-03. 

Thanks.

Original issue reported on code.google.com by efy...@gmail.com on 30 Nov 2011 at 7:03