Very large SOAP response - Android- out of memory error -
i have application need download large amount of data via soap call webservice application when first run. response sent function converts xml , stores data in db file.
the data more 16mb in size , have java.lang.outofmemoryerror everytime.
modifying webservice give out smaller amounts of data not option.
is there way able download large data? inputstream perhaps?
this code
public protocol[] getprotocols() { string method_name = "getprotocols"; string soap_action = "urn:protocolpedia#getprotocols"; log.d("service", "getprotocols"); soapobject response = invokemethod(method_name, soap_action); return retrieveprotocolsfromsoap(response); } private soapobject invokemethod(string methodname, string soapaction) { log.d(tag, "invokemethod"); soapobject request = getsoapobject(methodname); soapserializationenvelope envelope = getenvelope(request); return makecall(envelope, methodname, soapaction); }
can suggest should done in case?
thanks , regards mukul
two strategies solve problem:
- save soap xml stream directly disk download it. don't store in memory.
- parse using sax-style parser, don't load whole dom in memory, rather parse in chunks.
depending on kind of xml handling, using sax parsers harder in code; have keep track of many things yourself, , won't able "jump" section section of dom tree. memory consumption way lower.
take note, however, many "high-level" network communication libraries load whole xml dom in memory, might case here. have create , manage http connection yourself, , manually parse result.
Comments
Post a Comment