Skip to content

Fix ResizeObserver memory leak in matrix view#19

Merged
byemaxx merged 2 commits intostagingfrom
copilot/sub-pr-16-another-one
Jan 7, 2026
Merged

Fix ResizeObserver memory leak in matrix view#19
byemaxx merged 2 commits intostagingfrom
copilot/sub-pr-16-another-one

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 7, 2026

The ResizeObserver created in drawComparisonMatrix() was never disconnected when switching views or recreating the matrix, causing observers to accumulate in memory.

Changes

Store enhancement (comparison-renderer-store.js):

  • Added resizeObserver field and methods: setResizeObserver(), getResizeObserver(), disconnectResizeObserver()
  • Updated clear() to automatically disconnect observer

Cleanup integration (comparison-renderer.js):

  • Store observer reference when creating matrix view
  • Disconnect observer before clearing container in drawComparisonTree() and drawInlineFocusedComparison()

Cleanup scenarios

Observer is now disconnected when:

  • Switching between view modes (matrix → tree, matrix → focused)
  • Recreating matrix view (via matrixStore.clear())
  • Replacing existing observer (auto-disconnect in setResizeObserver())
// In drawComparisonMatrix
const resizeObserver = new ResizeObserver(() => { /* ... */ });
resizeObserver.observe(matrixContainer);
matrixStore.setResizeObserver(resizeObserver);  // Stored for cleanup

// In view switching functions
cleanupStore.disconnectResizeObserver();  // Explicit cleanup
vizContainer.innerHTML = '';

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: byemaxx <44231502+byemaxx@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix matrix layout and export cropping issues based on feedback Fix ResizeObserver memory leak in matrix view Jan 7, 2026
Copilot AI requested a review from byemaxx January 7, 2026 00:24
@byemaxx byemaxx marked this pull request as ready for review January 7, 2026 00:25
@byemaxx byemaxx merged commit eeab19f into staging Jan 7, 2026
@byemaxx byemaxx deleted the copilot/sub-pr-16-another-one branch January 7, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants