[v1] StyleStore leaks memory
Closed this issue ยท 1 comments
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:
Here's the corresponding entry in the JS heap snapshot:
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
๐ This issue has been resolved in version v2.5.0 ๐
The release is available on v2.5.0
Your semantic-release bot ๐ฆ๐