On Aug 28, 2011, at 6:34 AM, Willem Meints wrote:
> In my app I’m getting a crash with the promising message: “Excessive JNI 
> global references”.
> The runtime is right, I have too many of them and I do want to fix the issue, 
> however there’s one little hiccup.
...
> Is there any way I can fix this problem? For example, can I use another 
> technique to implement the GetItem method of the BaseAdapter class?

This bears further research, but I _think_ you may be able to use 
Android.Runtime.JavaList. JavaList is backed by a java.util.ArrayList in the 
Dalvik vm; thus, you'll need a GREF for the JavaList instance itself, but 
anything stored within the JavaList shouldn't take out any additional GREFs. 
(In theory; again, this bears testing.)

I would suggest that you try using e.g. ArrayAdapter (or a subclass of 
ArrayAdapter), and for the ArrayAdapter(Context, int, IList) constructor 
providing your JavaList instance. (This may require subclassing ArrayAdapter if 
you don't want to provide the otherwise required TextView id; see the 
ArrayAdapter documentation for details [0].) If you use ArrayAdapter and/or 
ArrayAdapter<T>, you may also be able to avoid using the JavaObjectWrapper<T> 
type, and let ArrayAdapter<T> handle the type conversions for you (though I'm 
not entirely sure this would work).

Thanks,

 - Jon

[0] http://docs.mono-android.net/index.aspx?link=T%3aAndroid.Widget.ArrayAdapter

_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to