Java – JNI local reference table summary (512 entries)
I have more than 10000 city names that I want to display in listview I store these names as cities in the RES / values folder XML file
as follows
<resources> <string-array name="city"> <item> chennai,India </item> <item> Spring Creek,Australia </item> . .
Then I create an arrayadapter and populate listview. XML like this
String[] cityDetails = res.getStringArray(R.array.city); // <-- getting Error in this line myAdapter = new ArrayAdapter<String>(this,R.layout.ap_details_row,R.id.aNameTV,cityDetails ); myLV.setAdapter(myAdapter);
It runs well in API class 13 and above equipment However, under the API level 13 device, I received the following error
W/dalvikvm(306): ReferenceTable overflow (max=512) W/dalvikvm(306): Last 10 entries in JNI local reference table: W/dalvikvm(306): 502: 0x45fbb330 cls=Ljava/lang/String; (28 bytes) W/dalvikvm(306): 503: 0x45fbb388 cls=Ljava/lang/String; (28 bytes) W/dalvikvm(306): 504: 0x45fbb3e0 cls=Ljava/lang/String; (28 bytes) W/dalvikvm(306): 505: 0x45fbb438 cls=Ljava/lang/String; (28 bytes) W/dalvikvm(306): 506: 0x45fbb498 cls=Ljava/lang/String; (28 bytes) W/dalvikvm(306): 507: 0x45fbb4f8 cls=Ljava/lang/String; (28 bytes) W/dalvikvm(306): 508: 0x45fbb558 cls=Ljava/lang/String; (28 bytes) W/dalvikvm(306): 509: 0x45fbb5d0 cls=Ljava/lang/String; (28 bytes) W/dalvikvm(306): 510: 0x45fbb638 cls=Ljava/lang/String; (28 bytes) W/dalvikvm(306): 511: 0x45fbb698 cls=Ljava/lang/String; (28 bytes) W/dalvikvm(306): JNI local reference table summary (512 entries): W/dalvikvm(306): 3 of Ljava/lang/Class; 164B (2 unique) W/dalvikvm(306): 507 of Ljava/lang/String; 28B (507 unique) W/dalvikvm(306): 1 of [Ljava/lang/String; 28B W/dalvikvm(306): 1 of [Ljava/lang/String; 37436B W/dalvikvm(306): Memory held directly by tracked refs is 51988 bytes E/dalvikvm(306): Failed adding to JNI local ref table (has 512 entries) I/dalvikvm(306): "main" prio=5 tid=1 RUNNABLE I/dalvikvm(306): | group="main" sCount=0 dsCount=0 s=N obj=0x4001d8e0 self=0xccb0 I/dalvikvm(306): | sysTid=306 nice=0 sched=0/0 cgrp=default handle=-1345026008 I/dalvikvm(306): | schedstat=( 1050455605 562911400 652 ) I/dalvikvm(306): at android.content.res.AssetManager.getArrayStringResource(Native Method) I/dalvikvm(306): at android.content.res.AssetManager.getResourceStringArray(AssetManager.java:186) I/dalvikvm(306): at android.content.res.Resources.getStringArray(Resources.java:381) I/dalvikvm(306): at com.mypro.main.HomeActivity.onCreate(HomeActivity.java:184) I/dalvikvm(306): at dalvik.system.NativeStart.main(Native Method) E/dalvikvm(306): VM aborting
Any help will be greatly appreciated
Solution
Some ideas:
1 - display one page of data at a time As you scroll down, load more data
2 - rolling 10000 records to the end will take forever Access your data through the search form Limit the results to 100 records
3 - if the data is sorted, please group the items together and provide the index For example, the alphabet can be divided into 26 subsets The first page displays the alphabet. You must click a letter to go to the subset