amplitude / Amplitude-Kotlin

Amplitude Kotlin SDK
MIT License
27 stars 10 forks source link

App Crashes with java.lang.OutOfMemoryError: Failed to allocate a 32 byte allocation with 672880 free bytes and 657KB until OOM #208

Closed BalaDakshina closed 1 month ago

BalaDakshina commented 1 month ago

Expected Behavior

App Should not crash when using Kotlin version of Amplitude SDK.

Current Behavior

App Crashes due to amplitude SDK running out of memory

Steps to Reproduce

  1. integrate the kotlin version of the SDK
  2. Run the app with invalid/fake apiKey.
  3. Error Log before crash:
Event storage file not found: /data/user/0/com.ford.fcsdriverinterface.mock/app_amplitude-disk-queue/$default_instance-15-1722867019549-447: open failed: ENOENT (No such file or directory)
Event storage file not found: /data/user/0/com.ford.fcsdriverinterface.mock/app_amplitude-disk-queue/$default_instance-15-1722867019549-447: open failed: ENOENT (No such file or directory)
Google Play Services SDK not found for app set id!
user id and device id are null; amplitude may not resolve identity
Event storage file not found: /data/user/0/com.ford.fcsdriverinterface.mock/app_amplitude-disk-queue/$default_instance-15-1722867020387-898: open failed: ENOENT (No such file or directory)
Event storage file not found: /data/user/0/com.ford.fcsdriverinterface.mock/app_amplitude-disk-queue/$default_instance-15-1722867020727-257: open failed: ENOENT (No such file or directory)
Event storage file not found: /data/user/0/com.ford.fcsdriverinterface.mock/app_amplitude-disk-queue/$default_instance-15-1722867021175-235: open failed: ENOENT (No such file or directory)
Event storage file not found: /data/user/0/com.ford.fcsdriverinterface.mock/app_amplitude-disk-queue/$default_instance-15-1722867020387-898: open failed: ENOENT (No such file or directory)
Event storage file not found: /data/user/0/com.ford.fcsdriverinterface.mock/app_amplitude-disk-queue/$default_instance-15-1722867020727-257: open failed: ENOENT (No such file or directory)
Event storage file not found: /data/user/0/com.ford.fcsdriverinterface.mock/app_amplitude-disk-queue/$default_instance-15-1722867021175-235: open failed: ENOENT (No such file or directory)
Event storage file not found: /data/user/0/com.ford.fcsdriverinterface.mock/app_amplitude-disk-queue/$default_instance-15-1722867020387-898: open failed: ENOENT (No such file or directory)
Event storage file not found: /data/user/0/com.ford.fcsdriverinterface.mock/app_amplitude-disk-queue/$default_instance-15-1722867020727-257: open failed: ENOENT (No such file or directory)
Event storage file not found: /data/user/0/com.ford.fcsdriverinterface.mock/app_amplitude-disk-queue/$default_instance-15-1722867021175-235: open failed: ENOENT (No such file or directory)
Event storage file not found: /data/user/0/com.ford.fcsdriverinterface.mock/app_amplitude-disk-queue/$default_instance-15-1722867021569-825: open failed: ENOENT (No such file or directory)```

4. Crash Log: 

```FATAL EXCEPTION: pool-42-thread-1
                                                                                                    Process: com.ford.fcsdriverinterface.mock, PID: 17717
                                                                                                    java.lang.OutOfMemoryError: Failed to allocate a 32 byte allocation with 672880 free bytes and 657KB until OOM, target footprint 201326592, growth limit 201326592; giving up on allocation because <1% of heap free after GC.
                                                                                                        at java.util.LinkedHashMap.newNode(LinkedHashMap.java:299)
                                                                                                        at java.util.HashMap.putVal(HashMap.java:636)
                                                                                                        at java.util.HashMap.put(HashMap.java:617)
                                                                                                        at org.json.JSONObject.put(JSONObject.java:276)
                                                                                                        at org.json.JSONTokener.readObject(JSONTokener.java:403)
                                                                                                        at org.json.JSONTokener.nextValue(JSONTokener.java:104)
                                                                                                        at org.json.JSONTokener.readArray(JSONTokener.java:449)
                                                                                                        at org.json.JSONTokener.nextValue(JSONTokener.java:107)
                                                                                                        at org.json.JSONArray.<init>(JSONArray.java:94)
                                                                                                        at org.json.JSONArray.<init>(JSONArray.java:110)
                                                                                                        at com.amplitude.core.utilities.FileResponseHandler.handleBadRequestResponse(FileResponseHandler.kt:62)
                                                                                                        at com.amplitude.core.utilities.ResponseHandler.handle(Response.kt:138)
                                                                                                        at com.amplitude.core.platform.EventPipeline$upload$1.invokeSuspend(EventPipeline.kt:145)
                                                                                                        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
                                                                                                        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)
                                                                                                        Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@66d8626, java.util.concurrent.Executors$FinalizableDelegatedExecutorService@2e5e267]

Environment

izaaz commented 1 month ago

@BalaDakshina - this has been fixed in version 1.17.1.