Skip to content

Comments

[WIP] URGENT: Memory leak in diagnosticbench-app-202504091010 causing 500 errors and downtime#48

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/fix-35
Draft

[WIP] URGENT: Memory leak in diagnosticbench-app-202504091010 causing 500 errors and downtime#48
Copilot wants to merge 1 commit intomainfrom
copilot/fix-35

Conversation

Copy link

Copilot AI commented Jul 15, 2025

  • Analyzed codebase and identified memory leak sources
  • Built and verified application compiles successfully
  • Fix event subscription memory leak in PublisherSubscriber.cs (2.1GB leak from 2,100 subscribers with 1MB each)
  • Fix static references preventing garbage collection in AppController.cs
  • Remove duplicate CreatePublishers() call in Program.cs
  • Add proper disposal patterns and reduce memory allocation
  • Test memory leak fixes
  • Verify application functionality remains intact

Root Cause Analysis:

  1. Primary Issue: Subscriber.CreatePublishers() creates 2,100 subscribers, each holding 1MB byte array (line 15: new byte[1024 * 1024]) with event subscriptions that never get unsubscribed (line 19), causing ~2.1GB permanent memory retention
  2. Secondary Issues: Static references in AppController (Processor p, memoryHog) prevent garbage collection
  3. Duplicate Calls: CreatePublishers() called both in Program.cs (line 30) and AppController.cs (line 17), doubling the memory leak

Memory Impact: Matches production incident showing 1.36GB in System.Byte[] with 1722 objects and GC root chains preventing cleanup.

Fixes #35.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

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.

URGENT: Memory leak in diagnosticbench-app-202504091010 causing 500 errors and downtime

2 participants