0

我不是要下载图像。我正在尝试从服务器获取 json 响应。当反应很小时,一切顺利。但是当我有一个巨大的反应时,我得到了一个例外。

10-19 16:32:12.226: E/dalvikvm-heap(5504): Out of memory on a 33554448-byte allocation.
10-19 16:32:12.230: I/dalvikvm(5504): "Thread-451" prio=5 tid=11 RUNNABLE
10-19 16:32:12.230: I/dalvikvm(5504):   | group="main" sCount=0 dsCount=0 obj=0x418c44d0 self=0x50ecd140
10-19 16:32:12.230: I/dalvikvm(5504):   | sysTid=5723 nice=0 sched=0/0 cgrp=apps handle=1361164216
10-19 16:32:12.230: I/dalvikvm(5504):   | schedstat=( 0 0 0 ) utm=176 stm=69 core=0
10-19 16:32:12.258: I/dalvikvm(5504):   at org.apache.http.util.CharArrayBuffer.expand(CharArrayBuffer.java:~59)
10-19 16:32:12.258: I/dalvikvm(5504):   at org.apache.http.util.CharArrayBuffer.append(CharArrayBuffer.java:77)
10-19 16:32:12.258: I/dalvikvm(5504):   at org.apache.http.util.EntityUtils.toString(EntityUtils.java:136)
10-19 16:32:12.258: I/dalvikvm(5504):   at org.apache.http.util.EntityUtils.toString(EntityUtils.java:146)
10-19 16:32:12.265: I/dalvikvm(5504):   at fr.haploid.webservices.parsers.WebServiceJSONObjectParser$MyNetworkThread.work(WebServiceJSONObjectParser.java:198)
10-19 16:32:12.265: I/dalvikvm(5504):   at fr.haploid.webservices.parsers.WebServiceParser$NetworkThread.run(WebServiceParser.java:653)
10-19 16:32:12.273: W/dalvikvm(5504): threadid=11: thread exiting with uncaught exception (group=0x40fb4300)
10-19 16:32:12.297: E/AndroidRuntime(5504): FATAL EXCEPTION: Thread-451
10-19 16:32:12.297: E/AndroidRuntime(5504): java.lang.OutOfMemoryError
10-19 16:32:12.297: E/AndroidRuntime(5504):     at org.apache.http.util.CharArrayBuffer.expand(CharArrayBuffer.java:59)
10-19 16:32:12.297: E/AndroidRuntime(5504):     at org.apache.http.util.CharArrayBuffer.append(CharArrayBuffer.java:77)
10-19 16:32:12.297: E/AndroidRuntime(5504):     at org.apache.http.util.EntityUtils.toString(EntityUtils.java:136)
10-19 16:32:12.297: E/AndroidRuntime(5504):     at org.apache.http.util.EntityUtils.toString(EntityUtils.java:146)
10-19 16:32:12.297: E/AndroidRuntime(5504):     at fr.haploid.webservices.parsers.WebServiceJSONObjectParser$MyNetworkThread.work(WebServiceJSONObjectParser.java:198)
10-19 16:32:12.297: E/AndroidRuntime(5504):     at fr.haploid.webservices.parsers.WebServiceParser$NetworkThread.run(WebServiceParser.java:653)
10-19 16:37:12.367: I/Process(5504): Sending signal. PID: 5504 SIG: 9

有谁知道我该如何解决这个问题?

4

1 回答 1

0

不幸的是,没有什么魔法可做!您需要更改 Web 服务以更轻松地发送 json 文件。我相信你可以将你的 json 文件分成几个部分。如果它是一个很长的列表,你可以考虑例如分页。

于 2012-10-19T15:14:52.100 回答