PERF: There seems to be a memory leakage in frontend-store

There seems to be a memory leakage in store.js file, when users browses through different topics, the _identityMap seems to be growing rapidly with each restful request. Without a proper cleanup logic, the map will exhaust memory with large js heaps.

Maybe adding a pruneMap function to the store.js, with FIFO algorithm to remove the earliest maps will be enough?

Also, the variable const MAX_ITEMS_PER_TYPE = 500; can be further discussed to set a balance between cache and memory storage.

1 Like

Can you tell us more about that?

Do you have any data to back this up?

(post deleted by author)

Reproduce steps is like the following: user skips from one topic to another using the “suggested/related” under the topic for multiple times without refreshing the page, and the js heap size will accumulate from the original 100MB to about 500MB, and 1GB+ if visited topics are enough(especially for topics with much posts under it). And returning to the homepage won’t release that part of occupied memory.

This js heap size can be seen from the browser console-performance, and the memory consumption can be seen from the process manager of the browser.

I’ll upload a video of this tomorrow.

1 Like