How to manage "Out of memory on an 5943816 byte allocation" when accessing xml string from server using ksoap in android application

StackOverflow https://stackoverflow.com/questions/17103610

Question

In my application, i am using ksoap2 for retrieving data from .net web service. Data which we are transferring is in format called "xml string". It works fine if i accesses 1000 item records. But When i am trying to access 12000 item records from server it is giving "Out of memory on an 5943816 byte allocation" error in my logcat.

////////////////// My code for retrieving data from server,

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                        SoapEnvelope.VER11);
request.addProperty("myparameter", myparameter);
envelope.dotNet = true;// to handle .net services asmx/aspx
envelope.setOutputSoapObject(request);

HttpTransportSE ht = new HttpTransportSE(MyURL);
ht.debug = true;

ht.call(SOAP_ACTION, envelope);
// to change dialog
publishProgress("Moving data file");

SoapObject resultString = (SoapObject) envelope.getResponse();

//////////////////

I know that this is because of heap size problem. But i dont know how to solve this, If any one have solution for this please help me..

Was it helpful?

Solution

Finally i found a way to solve the above problem, First i modified the .net service to return the number of lines the xml contains. Then i will request for bulk numbers of line which is under the heap size from service and write it into the local file. I repeat this until i get the last line in the xml from the server. After completing all lines, i use file for my further process.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top