Android开发当中的内存分配错误

基本都是内存不够分配,后来采取的是写外部文件的方法来完成的,参见http://www.iteye.com/topic/1014035
写了一个应用,估计把内存分配不够的问题全遇上了

1、
04-27 09:34:34.292: INFO/dalvikvm(9840): Jit: resizing JitTable from 4096 to 8192
04-27 09:56:19.612: DEBUG/dalvikvm(9840): GC_EXPLICIT freed 69K, 73% free 3838K/13767K, external 1175K/1569K, paused 115ms
04-27 09:56:21.062: INFO/ActivityManager(61): Process com.example.android (pid 9840) has died.
04-27 09:56:21.062: INFO/WindowManager(61): WIN DEATH: Window{40716078 com.example.android/com.example.android.Main paused=false}

04-27 10:32:46.042: INFO/dalvikvm-heap(18965): Clamp target GC heap from 16.226MB to 16.000MB
04-27 10:33:06.522: ERROR/GraphicsJNI(18965): VM won’t let us allocate 4096 bytes
04-27 10:32:30.382: INFO/ActivityManager(61): Process android.process.acore (pid 25279) has died.
04-27 10:32:30.382: INFO/ActivityManager(61): Low Memory: No more background processes.

2、
04-25 21:52:31.226: ERROR/AndroidRuntime(9853): Caused by: java.lang.OutOfMemoryError
04-25 21:52:31.226: ERROR/AndroidRuntime(9853): at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:93)
04-25 21:52:31.226: ERROR/AndroidRuntime(9853): at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:218)
04-25 21:52:31.226: ERROR/AndroidRuntime(9853): at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:175)
04-25 21:52:31.226: ERROR/AndroidRuntime(9853): at java.io.OutputStreamWriter.convert(OutputStreamWriter.java:252)
04-25 21:52:31.226: ERROR/AndroidRuntime(9853): at java.io.OutputStreamWriter.write(OutputStreamWriter.java:241)
04-25 21:52:31.226: ERROR/AndroidRuntime(9853): at java.io.BufferedWriter.write(BufferedWriter.java:224)
04-25 21:52:31.226: ERROR/AndroidRuntime(9853): at java.io.Writer.write(Writer.java:101)
04-25 21:52:31.226: ERROR/AndroidRuntime(9853): at java.io.Writer.write(Writer.java:155)
04-25 21:52:31.226: ERROR/AndroidRuntime(9853): at org.kxml2.io.KXmlSerializer.endTag(KXmlSerializer.java:508)

3、
04-25 19:51:44.196: INFO/dalvikvm-heap(6801): Forcing collection of SoftReferences for 1783864-byte allocation
04-25 19:51:44.216: ERROR/dalvikvm(6801): HeapWorker is wedged: 34640ms spent inside Lcom/android/internal/os/BinderInternal$GcWatcher;.finalize()V
04-25 19:51:44.216: INFO/dalvikvm(6801): DALVIK THREADS:
04-25 19:51:44.226: INFO/dalvikvm(6801): “main” prio=5 tid=3 VMWAIT
04-25 19:51:44.236: INFO/dalvikvm(6801): | group=”main” sCount=1 dsCount=0 s=N obj=0x4001b268 self=0xbd00
04-25 19:51:44.236: INFO/dalvikvm(6801): | sysTid=6801 nice=0 sched=0/0 cgrp=default handle=-1344001384
04-25 19:51:44.246: INFO/dalvikvm(6801): at android.app.ActivityThread.handleLowMemory(ActivityThread.java:~3840)
04-25 19:51:44.256: INFO/dalvikvm(6801): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1949)
04-25 19:51:44.256: INFO/dalvikvm(6801): at android.os.Handler.dispatchMessage(Handler.java:99)
04-25 19:51:44.266: INFO/dalvikvm(6801): at android.os.Looper.loop(Looper.java:123)
04-25 19:51:44.266: INFO/dalvikvm(6801): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-25 19:51:44.266: INFO/dalvikvm(6801): at java.lang.reflect.Method.invokeNative(Native Method)
04-25 19:51:44.266: INFO/dalvikvm(6801): at java.lang.reflect.Method.invoke(Method.java:521)
04-25 19:51:44.276: INFO/dalvikvm(6801): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-25 19:51:44.276: INFO/dalvikvm(6801): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-25 19:51:44.276: INFO/dalvikvm(6801): at dalvik.system.NativeStart.main(Native Method)
04-25 19:51:44.286: INFO/dalvikvm(6801): “Binder Thread #8″ prio=5 tid=27 NATIVE
04-25 19:51:44.286: INFO/dalvikvm(6801): | group=”main” sCount=1 dsCount=0 s=N obj=0x440ceef0 self=0x2fa898
04-25 19:51:44.286: INFO/dalvikvm(6801): | sysTid=7415 nice=0 sched=0/0 cgrp=default handle=2884512
04-25 19:51:44.286: INFO/dalvikvm(6801): at dalvik.system.NativeStart.run(Native Method)
04-25 19:51:44.286: INFO/dalvikvm(6801): “Binder Thread #7″ prio=5 tid=25 NATIVE
04-25 19:51:44.286: INFO/dalvikvm(6801): | group=”main” sCount=1 dsCount=0 s=N obj=0x43f82530 self=0x2e3248
04-25 19:51:44.286: INFO/dalvikvm(6801): | sysTid=7256 nice=0 sched=0/0 cgrp=default handle=3027464
04-25 19:51:44.286: INFO/dalvikvm(6801): at dalvik.system.NativeStart.run(Native Method)
04-25 19:51:44.286: INFO/dalvikvm(6801): “Binder Thread #6″ prio=5 tid=23 NATIVE
04-25 19:51:44.296: INFO/dalvikvm(6801): | group=”main” sCount=1 dsCount=0 s=N obj=0x43df2e98 self=0x2f7890
04-25 19:51:44.296: INFO/dalvikvm(6801): | sysTid=7074 nice=0 sched=0/0 cgrp=default handle=3112240
04-25 19:51:44.296: INFO/dalvikvm(6801): at dalvik.system.NativeStart.run(Native Method)
04-25 19:51:44.296: INFO/dalvikvm(6801): “Binder Thread #5″ prio=5 tid=21 NATIVE
04-25 19:51:44.296: INFO/dalvikvm(6801): | group=”main” sCount=1 dsCount=0 s=N obj=0x43ba60d8 self=0x2eea38
04-25 19:51:44.296: INFO/dalvikvm(6801): | sysTid=7008 nice=0 sched=0/0 cgrp=default handle=3057296
04-25 19:51:44.296: INFO/dalvikvm(6801): at dalvik.system.NativeStart.run(Native Method)
04-25 19:51:44.306: INFO/dalvikvm(6801): “Binder Thread #4″ prio=5 tid=19 NATIVE
04-25 19:51:44.306: INFO/dalvikvm(6801): | group=”main” sCount=1 dsCount=0 s=N obj=0x43c3a100 self=0x2e7358
04-25 19:51:44.306: INFO/dalvikvm(6801): | sysTid=6991 nice=0 sched=0/0 cgrp=default handle=3065008
04-25 19:51:44.306: INFO/dalvikvm(6801): at dalvik.system.NativeStart.run(Native Method)
04-25 19:51:44.316: INFO/dalvikvm(6801): “Binder Thread #3″ prio=5 tid=17 NATIVE
04-25 19:51:44.316: INFO/dalvikvm(6801): | group=”main” sCount=1 dsCount=0 s=N obj=0x43c19078 self=0x2e9618
04-25 19:51:44.316: INFO/dalvikvm(6801): | sysTid=6986 nice=0 sched=0/0 cgrp=default handle=3052944
04-25 19:51:44.316: INFO/dalvikvm(6801): at dalvik.system.NativeStart.run(Native Method)
04-25 19:51:44.326: INFO/dalvikvm(6801): “AsyncTask #1″ prio=5 tid=15 RUNNABLE
04-25 19:51:44.326: INFO/dalvikvm(6801): | group=”main” sCount=0 dsCount=0 s=N obj=0x43c3a250 self=0x2cf6e0
04-25 19:51:44.326: INFO/dalvikvm(6801): | sysTid=6977 nice=0 sched=0/0 cgrp=default handle=2946352
04-25 19:51:44.339: INFO/dalvikvm(6801): at java.nio.CharArrayBuffer.(CharArrayBuffer.java:~43)
04-25 19:51:44.346: INFO/dalvikvm(6801): at java.nio.ReadWriteCharArrayBuffer.(ReadWriteCharArrayBuffer.java:47)
04-25 19:51:44.346: INFO/dalvikvm(6801): at java.nio.BufferFactory.newCharBuffer(BufferFactory.java:84)
04-25 19:51:44.346: INFO/dalvikvm(6801): at java.nio.CharBuffer.allocate(CharBuffer.java:57)
04-25 19:51:44.356: INFO/dalvikvm(6801): at java.nio.charset.CharsetDecoder.allocateMore(CharsetDecoder.java:293)
04-25 19:51:44.356: INFO/dalvikvm(6801): at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:250)
04-25 19:51:44.356: INFO/dalvikvm(6801): at java.nio.charset.Charset.decode(Charset.java:768)
04-25 19:51:44.356: INFO/dalvikvm(6801): at java.lang.String.(String.java:238)
04-25 19:51:44.366: INFO/dalvikvm(6801): at java.io.ByteArrayOutputStream.toString(ByteArrayOutputStream.java:139)

4、
04-20 09:08:44.060: INFO/global(227): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
04-20 09:38:25.450: ERROR/AndroidRuntime(721): Caused by: java.lang.OutOfMemoryError
04-20 09:38:25.450: ERROR/AndroidRuntime(721): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:97)
04-20 09:38:25.450: ERROR/AndroidRuntime(721): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:155)
04-20 09:38:25.450: ERROR/AndroidRuntime(721): at java.lang.StringBuffer.append(StringBuffer.java:214)

5、
04-20 11:54:40.510: ERROR/dalvikvm-heap(4237): Out of memory on a 1672096-byte allocation.
04-20 11:54:40.510: INFO/dalvikvm(4237): “AsyncTask #1″ prio=5 tid=15 RUNNABLE
04-20 11:54:40.510: INFO/dalvikvm(4237): | group=”main” sCount=0 dsCount=0 s=N obj=0x43c1f610 self=0x2cb260
04-20 11:54:40.510: INFO/dalvikvm(4237): | sysTid=4270 nice=10 sched=0/0 cgrp=bg_non_interactive handle=2907136
04-20 11:54:40.510: INFO/dalvikvm(4237): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:~97)
04-20 11:54:40.510: INFO/dalvikvm(4237): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:155)
04-20 11:54:40.510: INFO/dalvikvm(4237): at java.lang.StringBuilder.append(StringBuilder.java:216)

6、
04-20 11:54:40.540: ERROR/AndroidRuntime(4237): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): java.lang.RuntimeException: An error occured while executing doInBackground()
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): at android.os.AsyncTask$3.done(AsyncTask.java:200)
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): at java.lang.Thread.run(Thread.java:1096)
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): Caused by: java.lang.OutOfMemoryError
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:97)
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:155)
04-20 11:54:40.550: ERROR/AndroidRuntime(4237): at java.lang.StringBuilder.append(StringBuilder.java:216)

7、
04-20 13:32:45.590: ERROR/dalvikvm(7314): Rejecting allocation of 2147483647-element array
04-20 13:32:45.640: ERROR/AndroidRuntime(7314): java.lang.OutOfMemoryError: array size too large

Leave a Reply

Your email address will not be published. Required fields are marked *