I have a mobile app that makes a call to a web service using an HttpWebRequest, and then parses it into a JArray. I am running into a memory issue when the JSON string is long (~20MB), where my iPad is receiving memory warnings and ultimately crashes.
When I exclude the JArray.Parse step, I do not see these memory warnings.
Are there any alternatives to building my JArray that would be more efficient memory-wise?
string longJsonStringFromWebService = "";
HttpWebRequest request = ...
using(WebResponse response = await request.GetResponseAsync())
{
using (StreamReader streamReader = new StreamReader(response.GetResponseStream())
{
longJsonStringFromWebService = reader.ReadToEnd();
}
}
...
JArray jsonArray = JArray.Parse(longJsonStringFromWebService);