Forum Xamarin.Android

OutOfMemoryError thrown while try to throw outofmemoryerror,no stack trace available

Hi, I am getting this error sometimes while trying to connect to my webapi. I am using HttpClient to get the data from webapi.
this error is not coming everytime, but sometime this error comes and display goes white and my android application got crashed. Trying to figure out the issue from last many days, but no luck so far. I am always creating new instance for my HTTPClient class.

I am using following approach to get data

    var progressDialog = ProgressDialog.Show(this, "", "Connecting...", true);
            var client = new HttpClient();
            var request = new PODetailRequest
                po = spinPo.SelectedItem.ToString(),
                poType = "P",
                barcode = barcode
            // create the request content and define Json  
            var json = JsonConvert.SerializeObject(request);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            //  send a POST request  
            var uri = clsGlobal.METHOD_GET_PO_ITEM_DETAILS;

            var result = await client.PostAsync(uri, content);


            // handling the answer  
            var resultString = await result.Content.ReadAsStringAsync();

            var response = JsonConvert.DeserializeObject<PODetailResponse>(resultString);
            //If item found against PO then add POItem List
            if (response.response == "Y")
                var PoItem = response.poDetails[0];
                //If item already exist then increase qty
                var ItemExist = _ListPoItemDetails.Find(x => x.itemCode == PoItem.itemCode && Convert.ToDecimal(x.mrp) == Convert.ToDecimal(PoItem.mrp));
                if (ItemExist != null)
                    int Index = _ListPoItemDetails.IndexOf(ItemExist);
                    PoItem.qty = 1;


                editScanbarcode.Text = "";
            else //if not found then add in other PO list
                    clsGLB.ShowMessage(response.errorMessage, this, MessageTitle.INFORMATION);
        catch (Exception ex)
            clsGLB.ShowMessage(ex.Message, this, MessageTitle.ERROR);


  • ArindamSarkarArindamSarkar Member ✭✭

    @amit5158 do you know how much data is coming in response? Size of the response and how long it takes to return response. Can you check this from Server side of the API.

  • amit5158amit5158 Member ✭✭

    Only one class object is coming from webapi, data size is not that much, this class has hardly 10 properties.Response time is quite good most of the time, since device is connected to wifi. It does not take much time

Sign In or Register to comment.