element-hq / element-hq/element-web

Element leaks every now and then

Open
#28,307 2 comments 0 reactions 0 assignees View on GitHub
A-Memory customer-support O-Occasional S-Minor T-Defect Z-Upstream
Dominant language
TypeScript
Stars
13.5k
Forks
2.8k
PR merge metrics
PR metrics pending

Description

### Steps to reproduce

1. Where are you starting? What can you see? We at Mozilla have seen some slow cycle collection times every now and then when using Element.
3. What do you click? N/A
4. More steps… This happens randomly and takes often some time to reproduce

### Outcome

#### What did you expect? No leak

#### What happened instead? memory usage goes up and GC/CC times too

Copy-pasting my comment from elsewhere:
I may have gotten some useful information about the Element leak. Happened to see that locally. At least in this case lots of the memory stays around because there is some function n which through enclosing_environment and other stuff keeps openEvent alive, and that is a pointer to a FocusEvent. (openEvent is still marked). Now, FocusEvent isn't skippable, and its mRelatedTarget and mOriginalRelatedTarget point to an orphan html:li element. CC doesn't know about that FocusEvent, and thus html:li have two unknown refs. html:li does have a preserved wrapper and of course that then keeps lots of stuff around (because of react stuff). So, a leak on the site. We should be able to decrease CC time quite a bit, but the leak is still there.

So seems like there is this "openEvent" somewhere through which lots of memory stays around. Or something is keeping openEvent around. The path is 'function n->Call->LexicalEnvironment->a->current->openEvent->FocusEvent'

My guess something somewhere is forgetting to clear openEvent, or that current.

### Operating system

_No response_

### Browser information

_No response_

### URL for webapp

_No response_

### Application version

_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.