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?

2 Likes

Can you tell us more about that?

Do you have any data to back this up?

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 in my test, 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 uploaded a video of this attached in the PR, just showcase the problem(about 3 mins, when using the same page for more hours, the situation will be worse)

And also adding a breakpoint here will showcase the growing amount of items in _identityMap

But I’m not quite sure if _identityMap is the root cause of this issue, just provide some info for investigation.

2 Likes

The PR above will address the memory leak reported in the OP. :smiley:

5 Likes