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);
        try
        {
            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);

            progressDialog.Hide();

            // 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);
                    _ListPoItemDetails[Index].qty++;
                }
                else
                {
                    PoItem.qty = 1;
                    _ListPoItemDetails.Add(PoItem);
                }

                _TotalQty++;
                SetListDataPoItem(_ListPoItemDetails);

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

Answers

  • 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 ✭✭

    Hi,
    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.