Skip to content

Remove alternate tree DOM element retainers to help with memory leak investigations #25391

@ling1726

Description

@ling1726

Hi,

#16087, #15157 (and other issues) point out that React keeps an alternate tree that can retain DOM elements in fibers such as the stateNode property. This can make it hard to debug memory leaks in larger sites/applications since they are a false positive.

To make the investigation process easier, would it be possible to recommend/suggest a way to somehow clean up the retainers in alternate fiber so that there is less noise?

We have some tools that do this to more or less successfully by pasring the fiber tree and setting alternate.stateNode to null.

I understand that fibers are internal API and that anything retained in alternate tree should fix itself eventually if the userland code is not leaky. However when there are leaks in userland the alternate tree can make root causing real memory leaks quite hard, even for those who are aware that retention in alternate trees is expected and a normal behaviour of React.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: StaleAutomatically closed due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions