You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey. We encountered a memory leak problem on server (nextjs page router) after update redux-toolkit from 1.9.5 to 2.4.0. After investigating the heap snapshot, we found that the problem was in the reselect (describe in reduxjs/reselect#635).
A temporary fix is to use this lruMemoize for createSelector instead of weakMapMemoize. But anyway I think this information should be described in the documentation (may be in migration guide) because this is clearly not expected behavior (I mean memory leak).
diagram after fallback to lruMemoize in 02/20:
The text was updated successfully, but these errors were encountered:
We would still very much like a reproduction of the situation you are seeing, but specific to a combination of SSR, default states, and selectors with primitive arguments, this repro might help to investigate: https://codesandbox.io/p/devbox/selectors-default-value-leak-c7g9rr
The problem here being that the initial state of slice, { items: [] } never leaves memory and will be returned for every store created, even if then different primitive selector arguments are used beyond that.
For debugging, I ran this locally and added this line to reselect.mjs
function weakMapMemoize(func, options = {}) {
let fnNode = createCacheNode();
+ (globalThis.rootNodes ??= []).push(fnNode)
const { resultEqualityCheck } = options;
Hey. We encountered a memory leak problem on server (nextjs page router) after update
redux-toolkit
from 1.9.5 to 2.4.0. After investigating the heap snapshot, we found that the problem was in the reselect (describe in reduxjs/reselect#635).A temporary fix is to use this
lruMemoize
for createSelector instead ofweakMapMemoize
. But anyway I think this information should be described in the documentation (may be in migration guide) because this is clearly not expected behavior (I mean memory leak).diagram after fallback to

lruMemoize
in 02/20:The text was updated successfully, but these errors were encountered: