简体   繁体   中英

how to programatically increase the JVM on android to 10MB?

is it possible to programatically increase the JVM android machine to 10MB? If yes can someone post a java code and let me know how to do it? I have a file of 11MB and I get the error out of memory when I try to parse the file in a string. Need help. appreciate

UPDATE:

I've also parse with SAX. Same result. When adding android:largeHeap=true I have error: No resource identifier found for attribute LargeHeap Any other solutions?

Can you answer, what exactly you trying to do?

If your app targets at honeycomb (android 3.0) and later you can try to set option android:largeHeap="true" in Application tag of your AndroidManifest.xml.

If you trying to parse JSON or XML, try to streaming aproach instead of tree-based.

UPDATE: In AndroidManifest.xml

...
<application android:largeHeap="true">
   ...
</application>
...

You are lucky if have a rooted phone. You can try change line

dalvik.vm.heapsize=24m

in /system/build.props.

If not, you can try to use the SAX library to parse your XML content. It can help to avoid to load full file at time, instead with this library you can load your data by small pieces.

ALSO: There are no JVM on android. There is Dalvik.

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