amplitude / Amplitude-Kotlin

Amplitude Kotlin SDK
MIT License
27 stars 10 forks source link

OOM loading properties file #152

Closed GrahamBorland closed 6 months ago

GrahamBorland commented 10 months ago

Expected Behavior

No crash

Current Behavior

Crash trying to allocate 228 MB when reading a properties file

java.lang.OutOfMemoryError: Failed to allocate a 228874864 byte allocation with 100663296 free bytes and 124MB until OOM, target footprint 238615760, growth limit 268435456
        at java.util.Properties.loadConvert(Properties.java:546)
        at java.util.Properties.load0(Properties.java:390)
        at java.util.Properties.load(Properties.java:337)
        at com.amplitude.id.utilities.PropertiesFile.load(PropertiesFile.kt:22)
        at com.amplitude.id.FileIdentityStorage.<init>(FileIdentityStorage.kt:23)
        at com.amplitude.id.FileIdentityStorageProvider.getIdentityStorage(FileIdentityStorage.kt:71)
        at com.amplitude.core.Amplitude$build$built$1.invokeSuspend(Amplitude.kt:105)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
        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)

Possible Solution

Steps to Reproduce

Reports captured in Bugsnag from end-users. We have no repro steps. It doesn't seem to be very common (9 instances so far).

Environment

com.amplitude:analytics-android:1.11.1

Pixel 6 pro running Android 14

justin-fiedler commented 6 months ago

Duplicate of #179.

v1.16.1 adds error handling to prevent the crash.