0

我从服务器获取数据为:

HttpTransportSE androidhttpTranport = new HttpTransportSE(URL, ContantSystem.TimeOut);
androidhttpTranport.call(SOAP_ACTIONS, envelope);
Object responseBody = responseBody = envelope.getResponse();

我的应用程序显示异常:

11-07 19:54:41.283: E/AndroidRuntime(10620): FATAL EXCEPTION: Thread-1851
11-07 19:54:41.283: E/AndroidRuntime(10620): java.lang.OutOfMemoryError
11-07 19:54:41.283: E/AndroidRuntime(10620):    at java.lang.String.<init>(String.java:432)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at java.lang.AbstractStringBuilder.toString(AbstractStringBuilder.java:642)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at java.lang.StringBuilder.toString(StringBuilder.java:663)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.kxml2.io.KXmlParser.readValue(KXmlParser.java:1419)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.kxml2.io.KXmlParser.next(KXmlParser.java:390)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.kxml2.io.KXmlParser.nextText(KXmlParser.java:2056)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.ksoap2.serialization.DM.readInstance(DM.java:34)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.ksoap2.serialization.SoapSerializationEnvelope.readInstance(SoapSerializationEnvelope.java:462)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:420)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:289)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:422)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:149)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:137)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:195)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at jp.osaka.APPLIActivity.getMarterDB(APPLIActivity.java:408)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at jp.osaka.APPLIActivity.access$0(APPLIActivity.java:390)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at jp.osaka.APPLIActivity$myrunable.run(APPLIActivity.java:369)
11-07 19:54:41.283: E/AndroidRuntime(10620):    at java.lang.Thread.run(Thread.java:856)

我的数据约为 2.4MB。(5.000.000 个字符)。我的设备内存有限制吗?为什么?

4

1 回答 1

1

内存限制是针对整个应用程序的,而不是仅针对 http 的。因此,您在应用程序的其他地方使用了大量内存,或者您的手机整体内存不足。很可能它是您的应用程序。在您的应用程序上运行 hprof 并查看您是否泄漏了引用。信不信由你,大型 Java 程序中的内存管理与 C++ 中的工作量一样多,而且 Android 的框架很容易泄漏大量传递给它的对象,例如活动。

于 2012-11-15T07:43:32.830 回答