[mono-android] Excessive JNI global references (2001) on hardware

Jonathan Pryor jonp at xamarin.com
Thu Feb 2 17:01:16 UTC 2012


On Feb 2, 2012, at 2:58 AM, PVoLan wrote:
> Catched same problem at:
> 
> Tablet LUNA RMD 7 with Android 2.3.1
> Phone Samsung GT-I5700 with Android 2.2.2 (firmware was updated by user from
> original 2.1)

What I find incredible is that there is shipping hardware with the emulator limits enabled instead of the (much higher!) device limits that we see elsewhere.

The fix is to ensure that you don't create too many global references...which can be rather hard to do. To help, you can enable gref logging:

	http://docs.xamarin.com/android/advanced_topics/diagnostics#Global_Reference_Messages

This will report when global references are being created, and you can improve the GREF count by either explicitly Dispose()ing of objects when you no longer need them or by calling GC.Collect() so that unreferenced objects will be collected. This still doesn't help if you in fact need to have lots of objects around at once; the answer here, sadly, is Don't Do That™ (or don't support hardware with such low limits).

We are working on improving the GC and global reference situation, but it won't be fixed overnight. :-/

 - Jon



More information about the Monodroid mailing list