iVis-at-Bilkent / cytoscape.js-context-menus

A Cytoscape.js extension to provide context menu around elements and core instance
MIT License
87 stars 41 forks source link

Fix memory leak when destroy component #59

Closed pmierkowski closed 3 years ago

pmierkowski commented 3 years ago

In file cytoscape-context-menus.js in line 122 there is added listener to document element: document.addEventListener('mouseup', onClick) but in the line 212 listener was removed from document.body element document.body.removeEventListener('mouseup', getScratchProp('hideOnNonCyClick')) which cause memory leaks in Angular 10.

ksdev-pl commented 3 years ago

Here's how it looks like before the fix: 1592137946-Screenshot_20210607_170946

Here's after: 3487074271-Screenshot_20210607_170958

It's a serious problem.

canbax commented 3 years ago

@pmierkowski Thank you this is a good catch. I suspect there are more memory leaks. After I call the destroy method of extension, all the event listeners should be removed. I see that still some event listeners are being called. If memory leaks are important for you, there are still memory leaks.

pmierkowski commented 3 years ago

@canbax Thank you for quick reaction. The above leak was the largest. I will watch them, if I find anything I fix it.