3

My company has a Phonegap application that's running into errors with UIWebView; it's hitting the 10MB memory cap. We're using .NET MVC4 as our backend.

This is due to a very large JSON response from a sync call. The JSON string (approximately 12 megs of data) is saved to memory, which causes a memory exception. Due to the way our application works, we have to send this data.

I'm considering using Oboe.JS to stream in the JSON response (to avoid the allocation of the full JSON object). I think that this may fix the issue on the frontend, but I'd like to stream the JSON response from the backend. I know that there are chunking methods, but I'd prefer not to use that option.

Currently, our controller method produces an object, serializes it to JSON, and sends the entire response. I would like to open a one-way HTTP stream, if possible, and asynchronously write JSON data to this stream (which Oboe would parse on the client side).

Are there any technologies that fit my use case, or can someone point me to some methods I may use to accomplish this? I don't need a two-way conduit - I just want to write the JSON to the HTTPstream as objects are produced.

Thank you.

Community
  • 1
  • 1
  • [This question](http://stackoverflow.com/questions/13268237/returning-a-json-stream-from-an-apicontroller) may contain some code which does what you want. – marapet Mar 12 '14 at 22:29
  • @marapet Thanks for the link! I took a look at that, but I'm not sure it's the same use case. To my eyes, it looks as though he's trying to avoid allocating a string in-memory, so he's writing directly to a stream, which is then returned, while I want something similar to SignalR or long-polling (but nothing really that complex; I just want to send my JSON data down while I have it). Basically, I want to open a stream with my client from my server, and then stream JSON to it asynchronously as it's available instead of returning an HTTP response with 12 megs of data. –  Mar 12 '14 at 23:08

0 Answers0