plaidev / karte-android-sdk

KARTE SDK for Android
https://karte.io/
Apache License 2.0
5 stars 3 forks source link

[core] App crashes with an out of memory error. #12

Closed wasnot closed 3 years ago

wasnot commented 3 years ago

Expected Behavior

App doesn't crash due to the SDK even if it runs out of memory .

Current Behavior

App crashes with an out of memory error.

Possible Solution

This issue has been fixed in core 2.9.1 https://developers.karte.io/docs/release-notes-android-sdk-v2#core-291

Steps to Reproduce

We can not reproduce this problem on our environment.

SDK Version

This problem occurs if you are using core 2.9.0 or lower.

Context Details

out of memory

Logs

Fatal Exception: android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed.
    at android.database.CursorWindow.(CursorWindow.java:108)
    at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
    at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:138)
    at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
    at io.karte.android.utilities.datastore.DataStore$Companion.read()
    at io.karte.android.utilities.datastore.Transaction.read()
    at io.karte.android.utilities.datastore.Persister$DefaultImpls.read$default()
    at io.karte.android.tracking.queue.Dispatcher.dequeue()
    at io.karte.android.tracking.queue.Dispatcher.access$dequeue()
    at io.karte.android.tracking.queue.Dispatcher$request$3.invoke()
    at io.karte.android.tracking.queue.Dispatcher$request$3.invoke()
    at io.karte.android.tracking.queue.RateLimit$decrementWithDelay$1.run()
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.os.HandlerThread.run(HandlerThread.java:61)

The following occurs when offline.

Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a xxx byte allocation with xx free bytes and xxMB until OOM, max allowed footprint xx, growth limit xx
    at java.lang.StringFactory.newStringFromChars(StringFactory.java:220)
    at java.lang.StringBuffer.toString(StringBuffer.java:671)
    at java.io.StringWriter.toString(StringWriter.java:210)
    at kotlin.io.TextStreamsKt.readText(:19)
    at io.karte.android.core.logger.Collector.uploadLog(:95)
    at io.karte.android.core.logger.Collector.collect(:76)
    at io.karte.android.core.logger.FileAppender$flush$1.run(:13)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.os.HandlerThread.run(HandlerThread.java:65)

Possible Implementation