Skip to content

[v1] StyleStore leaks memory #6646

@ej612

Description

@ej612

Describe the bug

Hi there,

My sincere apologies for bugging you with an issue with v1, but we're still stuck on it unfortunately.

I'm in the process of updating our project from 1.26.2 to 1.29.13 and I can't get our test suite to pass since Chrome crashes due to running out of memory (Chrome seems to have a hardcoded memory cap at 4.4GB). I have managed to track the issue down to the cleanup function of @ui5/webcomponents-react-base/dist/stores/StyleStore:

function subscribe(listener) {
    const listeners = getListeners();
    STORE_LOCATION[getStyleStoreListenersSymbol()] = [...listeners, listener];
    return () => {
        // vvvvv
        STORE_LOCATION[getStyleStoreListenersSymbol()] = listeners.filter((l) => l !== listener);
        // ^^^^^
    };
}

It seems like listeners is not properly torn down and leftover listeners accumulate over time:
image

Here's the corresponding entry in the JS heap snapshot:
image

I seem to have managed to make the tests pass by changing the cleanup to:

STORE_LOCATION[getStyleStoreListenersSymbol()] = [];

But I don't know if this is too brusque.

Thanks a lot in advance!

UI5 Web Components for React Version

1.29.13

UI5 Web Components Version

1.24.13

Browser

Chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions