@@ -816,51 +816,12 @@ export class UserSession {
816816 // Mark disposed for leak detection
817817 memoryLeakDetector . markDisposed ( `UserSession:${ this . userId } ` ) ;
818818
819- // GC after disconnect — force garbage collection and measure how much is freed.
820- // Rate-limited: at most once per 10 seconds across all sessions to avoid
821- // thrashing GC during crash cascades (many sessions disconnecting at once).
822- if ( this . userId && UserSession . canRunPostDisconnectGc ( ) ) {
823- const gcLogger = rootLogger . child ( { service : "gc-after-disconnect" } ) ;
824- setTimeout ( ( ) => {
825- try {
826- const memBefore = process . memoryUsage ( ) ;
827- const t0 = performance . now ( ) ;
828- Bun . gc ( true ) ;
829- const gcDurationMs = performance . now ( ) - t0 ;
830- const memAfter = process . memoryUsage ( ) ;
831- const freedBytes = memBefore . heapUsed - memAfter . heapUsed ;
832-
833- gcLogger . info (
834- {
835- feature : "gc-after-disconnect" ,
836- userId : this . userId ,
837- gcDurationMs : Math . round ( gcDurationMs * 10 ) / 10 ,
838- heapBeforeMB : Math . round ( memBefore . heapUsed / 1048576 ) ,
839- heapAfterMB : Math . round ( memAfter . heapUsed / 1048576 ) ,
840- freedMB : Math . round ( freedBytes / 1048576 ) ,
841- rssMB : Math . round ( memAfter . rss / 1048576 ) ,
842- sessionDurationSeconds,
843- } ,
844- `GC after disconnect (${ this . userId } ): ${ gcDurationMs . toFixed ( 1 ) } ms, freed ${ Math . round ( freedBytes / 1048576 ) } MB` ,
845- ) ;
846- } catch ( error ) {
847- gcLogger . error ( error , "GC after disconnect failed" ) ;
848- }
849- } , 0 ) ;
850- }
851- }
852-
853- // Rate limiter for post-disconnect GC: at most once per 10 seconds
854- private static lastPostDisconnectGc : number = 0 ;
855- private static POST_DISCONNECT_GC_COOLDOWN_MS = 10_000 ;
856-
857- private static canRunPostDisconnectGc ( ) : boolean {
858- const now = Date . now ( ) ;
859- if ( now - UserSession . lastPostDisconnectGc < UserSession . POST_DISCONNECT_GC_COOLDOWN_MS ) {
860- return false ;
861- }
862- UserSession . lastPostDisconnectGc = now ;
863- return true ;
819+ // gc-after-disconnect REMOVED — confirmed wasteful:
820+ // 31 calls/hour on US Central, 2,242ms total event loop blocking, freed 0 bytes
821+ // every single time. The gc-probe in SystemVitalsLogger provides the same
822+ // diagnostic data on a fixed 60s schedule without being triggered by user behavior.
823+ // See: cloud/issues/066-ws-disconnect-churn/spec.md (A7)
824+ // See: cloud/issues/067-heap-growth-investigation/spike.md
864825 }
865826
866827 /**
0 commit comments