My application is crashing when trying to parse a large XML file using SAXParser.
I found a question in SO regarding it here unanswered. It is working as intended when i reduce the size of the XML Here is my LogCat output.11-26 12:08:45.099: WARN/dalvikvm(218): threadid=17: thread exiting with uncaught exception (group=0x4001aa28)
11-26 12:08:45.109: ERROR/AndroidRuntime(218): Uncaught handler: thread Thread-9 exiting due to uncaught exception
11-26 12:08:45.220: ERROR/AndroidRuntime(218): java.lang.OutOfMemoryError
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at java.lang.Object.internalClone(Native Method)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at java.lang.Object.clone(Object.java:82)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:141)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at java.lang.StringBuilder.append(StringBuilder.java:282)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at com.google.android.iopex.SaxXMLHandler.characters(SaxXMLHandler.java:24)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at org.apache.harmony.xml.ExpatParser.text(ExpatParser.java:166)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at org.apache.harmony.xml.ExpatParser.append(Native Method)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:506)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:467)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at org.apache.harmony.xml.ExpatRea开发者_开发百科der.parse(ExpatReader.java:329)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:286)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at javax.xml.parsers.SAXParser.parse(SAXParser.java:361)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at javax.xml.parsers.SAXParser.parse(SAXParser.java:240)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at com.google.android.iopex.SaxParser.parse(SaxParser.java:22)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at com.google.android.iopex.iOPEXActivity$4.run(iOPEXActivity.java:112)
11-26 12:08:45.220: ERROR/AndroidRuntime(218): at java.lang.Thread.run(Thread.java:1060)
HERE is the code that i'm using to parse
There are heap restrictions for android, read the XML data in chunks from your file and parse it conveniently
Ninja edit:
As per Tseng : Caching List<DbEntry>
by reading 20-30 entries into it makes much more sense.
精彩评论