java.lang.OutOfMemoryError
at com.solvoterra.xmlengine.Element.<init>(Element.java:9)
at com.solvoterra.xmlengine.XML_Handler_Main.startElement(XML_Handler_Main.java:71)
at org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:146)
at org.apache.harmony.xml.ExpatParser.append(Native Method)
at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:505)
at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:492)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:308)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:264)
at com.solvoterra.xmlengine.Project_Man.readXML_File(Project_Man.java:148)
at com.solvoterra.xmlengine.Project_Man.run(Project_Man.java:83)
at java.lang.Thread.run(Thread.java:1102)
I can see from this the error has occurred whilst running a new process which only contains the function to SAX Parse an XML file into memory (RAM) I don’t know all the details as this information has been provided by an anonymous user on the market.
Before the function to Parse is called all buffers and memory is cleared of existing data.
Q: Is it possible that the user is trying to Parse a HUGE XML database into memory and the RAM allocated by his phone simply isn’t enough to handle his database?
Sax parsing method doesn’t load things in memory itself (as opposed to DOM). Only your way of handling events generated by SAX can cause memory overload.
If you allow your users to chose freely an XML source, you have to either:
Another reason for this OutOfMemoryError could be a memory leak in your application which is not related to your XML parser. For example, orientation changes, if not handled carefully, can easily cause memory leaks. If your application memory is saturated, the OutOfMemoryError can be triggered by ANY memory allocation, but this single memory allocation may not be responsible for the whole process memory saturation.