简体   繁体   中英

android java heap size exceeded

I populate a database with lots of entries, but after 7000 rows (about 600 entries), it throws java heap size limit exceeded. I tried to change the heap size in the config file of the avd from 32 to 64. I tried to put -Xmx1024 to change the heap size of all the java application (in control panel). Nothing worked so far, any suggestion? THanks in advance

up:

cv.put(KEY_NAME, "name");
cv.put(KEY_HOTNESS, "hotness");
cv.put(KEY_CALORIE, "50");
cv.put(KEY_FAT, "5");
cv.put(KEY_CARBS, "5");
cv.put(KEY_PROT, "5");
cv.put(KEY_MULTI, "1");
ourDatabase.insert(DATABASE_TABLE, null, cv);

Whenever you create and add to objects in java, it will consume some of your available heap space. Instead of trying to write out and process the massive amount of queries in your code, you should process the queries in small chunks, commit those changes, and move on to more data. This way, you're only ever using a small amount of the heap space at once. There really should be no reason you have to process all of these queries at once.

As per the comments above. Unless there is some reason these massive inserts are being generated from the app, you shouldn't be doing that within the application code. Your database should be populated from outside the application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM