Skip to content

Graph instances never disposed on tab close, cytoscape, konva layer, autosave timer all leak #338

@avinxshKD

Description

@avinxshKD

sent #329 to fix the resize listener cleanup but that only scratched the surface. The actual leak is deeper . The actual cytoscape instance created in GraphArea.jsx - initialiseNewGraph() is never destroyed. No dispose() or destroy() method exists anywhere in the graph class chain (1-core through 6-server). When a tab closes, TabBar.jsx - closeTab() dispatches REMOVE_GRAPH, component unmounts, resize listener is removed and everything else stays alive: this.cy (full cytoscape instance + canvas + WebGL context), the Konva stage from cytoscape-node-editing, the edgehandles plugin state, and this.autoSaveIntervalId in 5-load-save.js which keeps firing setTimeout on a dead instance trying to write localStorage for a graph that no longer exists in state.

Open 10 tabs, close them, heap grows linearly, never recovers.

Fix can be, add dispose() to 1-core.js calling this.cy.destroy() + clearTimeout(this.autoSaveIntervalId) + null out refs. Call it from the useEffect cleanup in GraphArea.jsx alongside the existing resize unbind. Optionally also from closeTab() in TabBar.jsx before dispatching REMOVE_GRAPH.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions