-
Notifications
You must be signed in to change notification settings - Fork 339
Open
Labels
bugSomething isn't workingSomething isn't working
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.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working