ngrx / platform

Reactive State for Angular
https://ngrx.io
Other
7.96k stars 1.95k forks source link

Memory Leak at high message rate in v14 #4310

Closed patolax closed 2 months ago

patolax commented 2 months ago

Which @ngrx/* package(s) are the source of the bug?

effects, store

Minimal reproduction of the bug/regression with instructions

My angular application has to load updates from the backend 20 messages/sec. For this, we load all entities (Assets) from the backend as a snapshot at the start and then get incremental updates say 20 messages/sec. All assets are stored in a redux store and we use ngrx actions/effects to get data and update the store from the backend service (LoadAssetByIdAction is used by the effect to call the backend and LoadAssetByIdSucessAction updates the store upon receiving data).

As shown in the image, at the start we have only a very low count of objects and the memory the app is using is low (26MB). However, if I keep this for a while memory ballons to 76MB and there is a huge amount of objects retained in the memory. If this is left overnight browser tab crashes after the tab consumes over 1GB of memory.

My question is why is this happening and is there a way to resolve this issue?

Expected behavior

No memory leak

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)

"@angular/core": "^14.2.12", "@angular/forms": "^14.2.12", "@angular/material": "^14.2.7", "@ngrx/effects": "14", "@ngrx/entity": "14", "@ngrx/router-store": "14", "@ngrx/schematics": "14", "@ngrx/store": "14", "ngrx-store-freeze": "^0.2.4", "ngrx-store-logger": "^0.2.4",

Other information

image

No response

I would be willing to submit a PR to fix this issue