Skip to content

feat: Add analyze_heapsnapshot_contexts MCP tool - #2791

Merged
Lightning00Blade merged 1 commit into
ChromeDevTools:mainfrom
dinfuehr:di/unused-context-field
Sep 23, 2026
Merged

Lightning00Blade merged 1 commit into
ChromeDevTools:mainfrom
dinfuehr:di/unused-context-field

Conversation

@dinfuehr

@dinfuehr dinfuehr commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Add a MCP tool for detecting dead context variables in a heap snapshot. It can detect for example cases like this:

function setupUserSession(userId) {
  const largeBuffer = new ArrayBuffer(10 * 1024 * 1024); // 10MB
  let isOnline = true;

  // Force largeBuffer into context.
  fetch('/api/sync').then(() => {
    processData(largeBuffer);
  });

  // Long-lived event listener uses isOnline in same
  // context object and keeps alive largeBuffer.
  window.addEventListener('online', () => {
    updateStatus(userId, isOnline);
  });
}

@dinfuehr
dinfuehr force-pushed the di/unused-context-field branch 3 times, most recently from 20430c4 to 8f3bd7d Compare September 22, 2026 08:30
@dinfuehr
dinfuehr force-pushed the di/unused-context-field branch from 8f3bd7d to fb8a1ce Compare September 23, 2026 08:22
Comment thread tests/formatters/HeapSnapshotFormatter.test.ts Outdated
Comment thread src/tools/memory.ts Outdated
@dinfuehr
dinfuehr force-pushed the di/unused-context-field branch from fb8a1ce to af4f2c5 Compare September 23, 2026 13:09
@dinfuehr
dinfuehr force-pushed the di/unused-context-field branch from af4f2c5 to 5fb0d28 Compare September 23, 2026 13:13
@dinfuehr

Copy link
Copy Markdown
Collaborator Author

Thanks a lot for the review! I've updated the PR, so PTAL again

@Lightning00Blade Lightning00Blade left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM!

@Lightning00Blade
Lightning00Blade added this pull request to the merge queue Sep 23, 2026
Merged via the queue into ChromeDevTools:main with commit 190aeee Sep 23, 2026
20 checks passed
@dinfuehr
dinfuehr deleted the di/unused-context-field branch September 23, 2026 14:48
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