breautek commented on issue #1724:
URL: 
https://github.com/apache/cordova-android/issues/1724#issuecomment-2252840906

   > Is there anyway in which we can read the jsonArray in chunks and avoid 
holding the whole data in memory?
   
   Kind of, but it will be on the plugin author. Cordova supports APIs that 
makes use of a callback several times. So the plugin could have an API that 
retains the callback and invokes it several times. This means the plugin could 
chunk the response and only send parts of the dataset in reasonably sized 
chunks back to the webview, until all data is sent over.
   
   Otherwise you'll likely need to page your SQL queries to limit the data 
being returned, potentially requiring multiple query calls to build the 
complete dataset.
   
   > Even though I haven't found out what piece of data that is so big that can 
lead to this. fyi I don't store files (image/video/file) in memory
   
   It's probably just the number of records being returned, or the amount of 
string manipulation occurring. The problem with strings is it requires 
contiguous memory. Each string manipulation involves allocating a new block of 
contiguous memory and copying over the old part + the new part to form the new 
string. Even if you're not actually exhausting RAM, you could still run into 
OOM simply because the RAM is so fragmented that you cannot allocate the size 
of contiguous memory to fit the new string.
   
   Even if the native side can fully build the stringified JSON, it needs to 
send it over to JS which is another copy operation, and inside JS everytime 
that string variable is passed through to a function it's passed by value for 
string types, and thus it's copied again.
   
   I'm closing this issue because it isn't a bug with Cordova.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to