KXmlParser中的OutOfMemoryError

时间:2012-11-15 07:39:32

标签: android kxml2

我从服务器获取数据:

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个字符)。我的设备的内存是否有限制?为什么呢?

1 个答案:

答案 0 :(得分:1)

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