Closed
Description
Version
3.1.0
Reproduction link
https://jsfiddle.net/mrj8spu0/
Steps to reproduce
- Open the JSFiddle link mentioned as part of this issue.
- Check and record the heap memory in the browser on initial stage.
- Click on the "Register" button to dynamically register Module B 100 times
- Now we will see an increase in heap memory on account of registering module 100 times.
- Click on "Un-Register" button to dynamically un-register Module B 100 times
- Check the heap memory again, at this point will see an jump in memory usage on account of un-registering 100 module.
What is expected?
Heap memory generated on step 3 & 5 must be cleared after step 6. (Final stage)
What is actually happening?
Heap memory of the browser is not getting cleared.
We are observing memory leak of Store._vm while using registerModule/unregisterModule extensively.
On heap profiling we found that the oldVm instance is not getting garbage collected.
Probable Solution:
De-reference the oldVm instance on the same function scope where its getting instantiated (i.e. resetStoreVM() )
The above can be achieved by adding following code inside resetStoreVM function.
oldVm.$destroy();
oldVm = null; // This is the missing code
Attached google chrome (V 72.0.3626.96) heap snapshot and file.
Metadata
Metadata
Assignees
Labels
No labels