chriskhongqarma opened a new issue, #1724:
URL: https://github.com/apache/cordova-android/issues/1724

   # Bug Report
   
   ## Problem
   My Android app uses this [sqlite 
plugin](https://github.com/storesafe/cordova-sqlite-storage) for data 
persistence. 
   The app crashes on starting up with the following stack trace:
   `java.lang.OutOfMemoryError: Failed to allocate a 150994952 byte allocation 
with 100663296 free bytes and 141MB until OOM, target footprint 220905960, 
growth limit 268435456
   at java.util.Arrays.copyOf(Arrays.java:3578)
   at 
java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:177)
   at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:753)
   at java.lang.StringBuilder.append(StringBuilder.java:257)
   at org.json.JSONStringer.string(JSONStringer.java:354)
   at org.json.JSONStringer.value(JSONStringer.java:261)
   at org.json.JSONArray.toString(JSONArray.java:587)
   at org.apache.cordova.PluginResult.<init>(PluginResult.java:49)
   at org.apache.cordova.CallbackContext.success(CallbackContext.java:88)
   at 
io.sqlc.SQLiteConnectorDatabase.executeSqlBatch(SQLiteConnectorDatabase.java:172)
   at io.sqlc.SQLitePlugin$DBRunner.run(SQLitePlugin.java:341)
   at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
   at java.lang.Thread.run(Thread.java:1012)
   `
   ### What does actually happen?
   The root cause is that it tries to convert a large json object into a string 
in memory, which leads to out of memory exception.
   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
   The error traces back to PluginResult.java, line 49.
   `
   public PluginResult(Status status, JSONArray message) {
           this.status = status.ordinal();
           this.messageType = MESSAGE_TYPE_JSON;
           encodedMessage = message.toString();
       }
   `
   
   Is there anyway in which we can read the jsonArray in chunks and avoid 
holding the whole data in memory?
   
   ### Environment, Platform, Device
   Platform: Android
   Device: Redmi K70 on Xiaomi HyperOS version 1.0.11.0
   
   
   ### Version information
   Cordova android version 12.0.0
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to