element-hq / element-hq/element-web

v8 heap usage is larger than I'd expect with LL enabled.

Open
#22,119 5 comments 0 reactions 0 assignees View on GitHub
A-Lazy-Loading A-Memory A-Performance O-Occasional S-Minor T-Defect
Dominant language
TypeScript
Stars
13.5k
Forks
2.8k
PR merge metrics
PR metrics pending

Description

### Steps to reproduce

I just did a heap snapshot about 20 minutes after launching Element Nightly and was surprised to see it contained 192,329 MatrixEvent objects and 157,401 RoomMember objects:

Screenshot 2022-05-09 at 11 46 20

(heap available if needed).

This feels crazily high, given the whole point of membership Lazy Loading is to only load members for the rooms your client is interacting with, and I had only viewed 3 rooms, each with <50 users present, at that point in time.

It's possible that given this is after ~12h of incremental sync, processing E2EE traffic in all my other rooms had caused their memberships to be loaded (in order to speak E2EE) - but i'm still surprised this resulted in as many as 157K room members. The 35K non-member events also feels way too high.

Is it possible that threads is leaking events, or triggering membership loads which then undermines the memory improvements of lazy loading?

This might also be contributing to the OOM in https://github.com/vector-im/element-desktop/issues/680

### Outcome

#### What did you expect?

Roughly 300MB of heap to be in use on a fresh launch

#### What happened instead?

Roughly 600MB of heap to be in use, which may leak further, and might also be causing OOMs overnight. Will update this bug with further heapdumps which will hopefully differentiate between LL membership warming up and actual leaks.

### Operating system

macOS 12.3 on M1

### Application version

Nightly

### How did you install the app?

_No response_

### Homeserver

_No response_

### Will you send logs?

No

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.