Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
170 views
in Technique[技术] by (71.8m points)

java - OutOfMemoryError what to increase and how?

I have a really long collection with 10k items, and when running a toString() on the object it crashes. I need to use this output somehow.

05-21 12:59:44.586: ERROR/dalvikvm-heap(6415): Out of memory on a 847610-byte allocation.
05-21 12:59:44.636: ERROR/dalvikvm(6415): Out of memory: Heap Size=15559KB, Allocated=12932KB, Bitmap Size=613KB
05-21 12:59:44.636: ERROR/AndroidRuntime(6415): Uncaught handler: thread main exiting due to uncaught exception
05-21 12:59:44.636: ERROR/AndroidRuntime(6415): java.lang.OutOfMemoryError
05-21 12:59:44.636: ERROR/AndroidRuntime(6415):     at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:97)
05-21 12:59:44.636: ERROR/AndroidRuntime(6415):     at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:155)
05-21 12:59:44.636: ERROR/AndroidRuntime(6415):     at java.lang.StringBuilder.append(StringBuilder.java:202)
05-21 12:59:44.636: ERROR/AndroidRuntime(6415):     at java.util.AbstractCollection.toString(AbstractCollection.java:384)

I need step by step guide how to increase the heap for and Android application. I don't run the command line.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It seems that there is a hard limit of 16 MB heap space on Android apps that can only be worked around by altering the Android source. Your program has hit this limit: "Out of memory: Heap Size=15559KB". You'll need to figure out how to reduce your program's memory usage. A nice guide to doing this is here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...