infinitered / infinitered/reactotron

WebSocket related memory leak

Open
#1,175 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.6k
Forks
972
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the crash with Reactotron enabled and compare memory usage with it disabled. Use the OkHttp WebSocketReader and RealWebSocket frames in the crash log as the investigation entry points, and check the reactotron-mst and reactotron-react-native versions in package.json. Done means the reproducible memory growth and eventual OutOfMemoryError no longer occur.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native
Domain
mobile-dev, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.