infinitered / reactotron

A desktop app for inspecting your React JS and React Native projects. macOS, Linux, and Windows.
https://docs.infinite.red/reactotron/
MIT License
14.92k stars 944 forks source link

WebSocket related memory leak #1175

Open sirsavary opened 4 years ago

sirsavary commented 4 years ago

Not entirely sure how to describe or report this bug as it seems to come and go (and has done so for months) but I'm currently able to trigger it simply be enable Reactotron. I understand the info is a bit sparse but I don't know how to track it down :man_shrugging:

Anyway, here goes: Reactotron appears to be causing a memory leak that is causing my app to crash. From the error message / logs it looks like something to do with WebSockets and/or OkHttp. With Reactotron disabled, the app remains stable with consistent memory usage. With it enabled, the app will crash... eventually. Sometimes within a few seconds, other times it might take upwards of ten minutes or more.

Here's a crash log:

FATAL EXCEPTION: OkHttp Dispatcher
Process: com.lckroom.client.mvp.debug, PID: 27008
java.lang.OutOfMemoryError: Failed to allocate a 146919656 byte allocation with 25165824 free bytes and 41MB until OOM, max allowed footprint 250575040, growth limit 268435456
    at java.lang.StringFactory.newStringFromBytes(StringFactory.java:225)
    at java.lang.StringFactory.newStringFromBytes(StringFactory.java:256)
    at okio.Buffer.readString(Buffer.java:713)
    at okio.Buffer.readUtf8(Buffer.java:684)
    at okhttp3.internal.ws.WebSocketReader.readMessageFrame(WebSocketReader.java:219)
    at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.java:105)
    at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.java:274)
    at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:214)
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:206)
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)

I'm using the latest stable version of the Reactotron client, here's what I have in my package.json:

"reactotron-mst": "3.1.3",
"reactotron-react-native": "4.0.3"

Apologies for the vagueness but I'm not quite sure how to investigate further. I've attempted heap analysis but I'm not skilled enough to spot the issue. Previously this bug happened once or twice a day, but now it's happening with every run. Reactotron is important to my workflow and I've love to have it working again.

devproivansurzhenko commented 4 years ago

In my case, it leaks if reactotron-react-native is not connected to Reactotron app (it is not related to configuration).

vitto-moz commented 4 years ago

I had the same issue with my react-native (android) application and struggled a long time to figure out what is the source of it. It appeared that in case the Reactotron cannot connect to the address you've set - it starts "caching the data" on the app side (caching is just assumption - I don't know exactly if it does, but the memory consumption goes up).

So everything would be alright for hours (less or more) and once your Wifi Router DHCP decides to change the IP address for the device, where Reactotron is opened - the memory consumption starts rising until the crash.

The solution is quite simple: DON'T USE REACTOTRON IN PRODUCTION BUILD

litinskii commented 2 years ago

Maybe add options to disable storing action if connection is lost

dusanristic commented 9 months ago

We experienced the same issue with Reactotron, which was causing a memory leak. This memory leak, in turn, led to the app crashing after some time of use.

Is there any update on this?

trickeyd commented 3 months ago

Same thing here.