Skip to content

Conversation

binzram
Copy link

@binzram binzram commented Apr 14, 2020

RecentlyOutOfMemoryError exceptions occurred when receiving high amount of PusherBeams notifications in our app.

Fatal Exception: java.lang.OutOfMemoryError: Could not allocate JNI Env
       at java.lang.Thread.nativeCreate(Thread.java)
       at java.lang.Thread.start(Thread.java:730)
       at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:941)
       at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1359)
       at okhttp3.ConnectionPool.put(ConnectionPool.java:153)
       at okhttp3.OkHttpClient$1.put(OkHttpClient.java:167)
       ...
       at com.pusher.pushnotifications.api.PusherLibraryHeaderInterceptor.intercept(PusherLibraryHeaderInterceptor.kt:13)
       ...

According to this stackoverflow post each new okHttpClient has his own connection pool.

By instantiating only one instance of the client future request add up in the same connection pool and runs memory efficient.

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

Successfully merging this pull request may close these issues.

2 participants