RocketChat / RocketChat/EmbeddedChat
Bug: Unbounded Memory Growth in Message Store Causing OOM Crashes
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 165
- Forks
- 381
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 1
Description
A memory management issue exists in the message store where messages are accumulated in memory without any upper bound. In active or high-traffic channels, this causes unbounded memory growth, eventually leading to Out-Of-Memory (OOM) crashes, especially on mobile devices.
Observed Behavior
The setMessages function appends incoming messages directly to the existing message array:
[...state.messages, ...newMessages]
There is no cap or eviction strategy applied. As a result:
- Messages accumulate indefinitely
- Memory usage grows linearly with channel activity
- Old messages are never released from memory
Why this is not good
- Mobile environments (React Native) have limited memory
- An ever-growing array of message objects prevents garbage collection
- Eventually, the JavaScript heap fills up
- The application crashes with an OOM error
This makes the application unstable and unusable for users in busy channels.
Steps to Reproduce
- Connect to a high-volume channel (for example,
general). - Leave the application running for an extended period (overnight).
- Monitor memory usage using profiling tools.
Expected Behavior
The message store should enforce a bounded memory strategy, such as:
- A fixed maximum number of messages (for example, 500)
- Dropping the oldest messages when the limit is exceeded
- Implementing a circular buffer or sliding window approach
This ensures predictable memory usage regardless of channel activity.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the message store's setMessages function, where the issue identifies direct accumulation with [...state.messages, ...newMessages]. Reproduce the growth in a high-volume channel and monitor memory usage; done means messages are bounded, older entries are released, and memory remains predictable during extended activity.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile-dev, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100