android excessive global references
I'm occassionally tripping the jni global reference limit for the android emulator. I'm trying to store around 2000 words along with definitions in my application and it's failing at either of two spots: if I use DOM to parse the xml file with all those references it fails when DOM pulls the tree into memory. If I use SAX it fails when I get to around the 2000th element.
Does anyone have a link to how I can disable the check (I understand it doesn't exist on the actual machines and I am trying to persist 2000 small objects in memory)? If not, is there a good way to debug this? The objects that are building up are strings:
09-20 16:24:00.278: WARN/dalvikvm(625): 1879 of Ljava/lang/String; 28B (1877 unique)
I tried starting the avd with -nojni
and using adb
to set dalvik.vm.checkjni
C:\android-sdk-windows\tools>adb shell getprop dalvik.vm.checkjni
false
Although l开发者_如何转开发ogcat shows "CheckJNI is Off", it stills dies a the globalref 2001 limit.
Also, after the parsing section, the memory winds up getting returned as I see:
09-20 16:31:23.238: DEBUG/dalvikvm(654): GC_EXPLICIT freed 1157 objects / 48208 bytes in 147ms
09-20 16:31:23.258: DEBUG/dalvikvm(654): GREF has decreased to 1799
09-20 16:31:23.278: DEBUG/dalvikvm(654): GREF has decreased to 1699
09-20 16:31:23.287: DEBUG/dalvikvm(654): GREF has decreased to 1599
09-20 16:31:23.309: DEBUG/dalvikvm(654): GREF has decreased to 1499
09-20 16:31:23.328: DEBUG/dalvikvm(654): GREF has decreased to 1399
09-20 16:31:23.338: DEBUG/dalvikvm(654): GREF has decreased to 1299
09-20 16:31:23.367: DEBUG/dalvikvm(654): GREF has decreased to 1199
09-20 16:31:23.367: DEBUG/dalvikvm(654): GREF has decreased to 1099
09-20 16:31:23.398: DEBUG/dalvikvm(654): GREF has decreased to 999
09-20 16:31:23.398: DEBUG/dalvikvm(654): GREF has decreased to 899
09-20 16:31:23.408: DEBUG/dalvikvm(654): GREF has decreased to 799
09-20 16:31:23.418: DEBUG/dalvikvm(654): GREF has decreased to 699
09-20 16:31:23.418: DEBUG/dalvikvm(654): GREF has decreased to 599
09-20 16:31:23.437: DEBUG/dalvikvm(654): GREF has decreased to 499
09-20 16:31:23.447: DEBUG/dalvikvm(654): GREF has decreased to 399
09-20 16:31:23.447: DEBUG/dalvikvm(654): GREF has decreased to 299
09-20 16:31:23.469: DEBUG/dalvikvm(654): GREF has decreased to 199
So I don't think it's my hashmap holding the word objects that is actually the problem. The only idea I have left is to cut the xml file into multiples, but that seems like a might inelegant solution.
Thanks a lot!
this is a bug in our expat-based XML parsers (both SAX and pull): http://code.google.com/p/android/issues/detail?id=12595
Although slightly slower than sax, excessive global references seem to disappear when using the XML Pull Parser.
精彩评论