Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of memory exception on Android #45

Closed
duydao opened this issue Dec 15, 2016 · 4 comments
Closed

Out of memory exception on Android #45

duydao opened this issue Dec 15, 2016 · 4 comments

Comments

@duydao
Copy link

duydao commented Dec 15, 2016

Thanks for this plugin, we really appreciate it!

I'm getting an out of memory exception when trying to store a 14MB JSON into the database:

Throwing OutOfMemoryError "Failed to allocate a 41535454 byte allocation with 16777216 free bytes and 28MB until OOM

The same JSON loads fine on an iPhone.

at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:146)
at java.lang.StringBuilder.append(StringBuilder.java:216)
at com.nolanlawson.cordova.sqlite.SQLitePlugin.appendPluginResult(SQLitePlugin.java:256)
at com.nolanlawson.cordova.sqlite.SQLitePlugin.pluginResultsToString(SQLitePlugin.java:213)
at com.nolanlawson.cordova.sqlite.SQLitePlugin.runInBackground(SQLitePlugin.java:67)
at com.nolanlawson.cordova.sqlite.SQLitePlugin.access$000(SQLitePlugin.java:24)
at com.nolanlawson.cordova.sqlite.SQLitePlugin$1.run(SQLitePlugin.java:56)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.os.HandlerThread.run(HandlerThread.java:61)
@nolanlawson
Copy link
Owner

It's probably just too large of an object to store in SQLite. Note that Cordova has a limitation where all data has to be serialized into strings when sent between the WebView and the native context.

You may want to look into WebSQL or IndexedDB, or break up your JSON object into smaller pieces.

@nolanlawson
Copy link
Owner

Also the reason it fails in Android but not iOS is probably just due to device differences

@danielehrhardt
Copy link

Is there a new fix?

@ganeshmogare
Copy link

@nolanlawson can you put some more light on "or break up your JSON object into smaller pieces"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants