Got java.lang.OutOfMemoryError Exception when fetching Base64String Image Value from .net WebService on android
===

Got the below mentioned Error while fetching data's from .net web service which sends Image value as base64 String.


This is webservice fetching code :

	public SoapObject fetchingImage(String url,String idaction){
		
		final String METHOD_NAME = "ImageMethodName";
		final String NAMESPACE = "http://tempuri.org/";
		final String SOAP_ACTION = NAMESPACE+METHOD_NAME;
		final String SSURL = url+"/Service.asmx";
		
		soapobj = new SoapObject(NAMESPACE,METHOD_NAME);

		soapobj.addProperty("Akey",key.trim());
		soapobj.addProperty("IDAction",idaction);
		
		callsdue_envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
		callsdue_envelope.dotNet=true;
		callsdue_envelope.setOutputSoapObject(soapobj);
		
		wshttpTransportSE = new HttpTransportSE(SSURL);
		wshttpTransportSE.debug=true;
		
		try{
			wshttpTransportSE.call(SOAP_ACTION,callsdue_envelope); //sends the request
			if(callsdue_envelope != null){
				getuserresult= (SoapObject) callsdue_envelope.getResponse();  //Get the response
				// Check for empty value
				if(String.valueOf(getuserresult.getProperty(1)).toString().trim().equalsIgnoreCase(String.valueOf("anyType{}").toString())){
					getuserresult = null;
					Log.i(TAG,"GetCallsActionOtherDetails : "+"No Fields Available");
					return (SoapObject)getuserresult;
				}
				else {
					return (SoapObject) getuserresult.getProperty(1);
				}
			}else{
				Log.i(TAG,"Response Envelope Error!");
			}
		}catch(OutOfMemoryError e){
			Log.i(TAG,"OutOfMemory");
			getuserresult = null;
			e.printStackTrace();
		}catch(Exception e){
			e.printStackTrace();
		}
		return (SoapObject) getuserresult.getProperty(1);
	}

When i send a request this code my heap memory increase from 4mb to 19mb and it explode outofmemory exception.

Logcat Error message :


07-20 10:37:01.096: WARN/System.err(280): java.lang.OutOfMemoryError
07-20 10:37:01.096: WARN/System.err(280):     at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:97)
07-20 10:37:01.096: WARN/System.err(280):     at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:155)
07-20 10:37:01.096: WARN/System.err(280):     at java.lang.StringBuffer.append(StringBuffer.java:214)
07-20 10:37:01.096: WARN/System.err(280):     at org.ksoap2.serialization.SoapObject.toString(SoapObject.java:621)
07-20 10:37:01.106: WARN/System.err(280):     at java.lang.StringBuffer.append(StringBuffer.java:198)
07-20 10:37:01.106: WARN/System.err(280):     at org.ksoap2.serialization.SoapObject.toString(SoapObject.java:621)
07-20 10:37:01.106: WARN/System.err(280):     at java.lang.StringBuffer.append(StringBuffer.java:198)
07-20 10:37:01.106: WARN/System.err(280):     at org.ksoap2.serialization.SoapObject.toString(SoapObject.java:621)
07-20 10:37:01.106: WARN/System.err(280):     at java.lang.String.valueOf(String.java:1985)
