Memory leak issue caused by creating listeners for each subscribe
anvial opened this issue · 4 comments
Prerequisites
Please answer the following questions for yourself before submitting an issue.
- [+] I am running the latest version
- [+] I checked the documentation and found no answer
- [+] I checked to make sure that this issue has not already been filed
- [+] I'm reporting the issue to the correct repository
Current Behavior
I had a memory leak issue caused by vis creating listeners for each subscribe I did on EventEmitters such as click and afterDrawing. The network.destroy called at ngOnDestroy does not unsubscribe from these listeners when the component is destroyed and created multiple times.
Expected Behavior
I expect that network.destroy will unsubscribe from events correctly.
Failure Information
...
Steps to Reproduce
- Create network
- Subscribe any event
- Destroy network
- Create network with the same name
- Subscribe any event
- You will get double listeners...
Reproduce code snippet
...
Context
- Angular version: 9
- NodeJS version: 12
- Operating System: Macos
thanks for the PR, any PR is welcome ;)
=)
I have this problem in my angular app when I several times (more then once) return to page, where I have ngx-vis element.
For now I solve this issue just generating the new visNetworkName in ngOnInit(). Of'course I use network.destroy in ngOnDestroy(), but I'm not sure that it work properly.
i'll update the vis-timeline dependency, maybe related to visjs/vis-timeline#453
Will post an update