Skip to content

Lift char-block detachment onto the reader interface#641

Merged
Hirogen merged 6 commits into
Developmentfrom
closing_the_block_detach_seam_leak
Jun 25, 2026
Merged

Lift char-block detachment onto the reader interface#641
Hirogen merged 6 commits into
Developmentfrom
closing_the_block_detach_seam_leak

Conversation

@Hirogen

@Hirogen Hirogen commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

The LogfileReader read loop type-checked reader is …System/…Direct at three sites (six branches) to call DetachBlocks(), reaching through the ILogStreamReaderMemory seam to the concrete readers. Adding a reader meant editing every site, and the Legacy reader was silently skipped — its pooling allocator was never detached and never disposed, orphaning its rented blocks (a latent ArrayPool leak).

Add DetachCharBlocks() to ILogStreamReaderMemory so the loop calls it unconditionally:

  • Direct: rename DetachBlocks() -> DetachCharBlocks(); drop the dead BlockAllocator => null shim.
  • System/Legacy: implement DetachCharBlocks() over their allocator and make BlockAllocator private — detachment is the only seam-crossing surface now.
  • Legacy: add the Dispose override System already had, closing the leak.
  • LogfileReader: six is-branches collapse to one DetachCharBlocks() call per site. Legacy now participates uniformly.

Tests migrated off reader.BlockAllocator onto the public DetachCharBlocks() seam.

BRUNER Patrick and others added 6 commits June 25, 2026 15:23
The LogfileReader read loop type-checked `reader is …System/…Direct` at three sites (six branches) to call DetachBlocks(), reaching through the ILogStreamReaderMemory seam to the concrete readers.
Adding a reader meant editing every site, and the Legacy reader was silently skipped — its pooling allocator was never detached and never disposed, orphaning its rented blocks (a latent ArrayPool leak).

Add DetachCharBlocks() to ILogStreamReaderMemory so the loop calls it unconditionally:

- Direct: rename DetachBlocks() -> DetachCharBlocks(); drop the dead `BlockAllocator => null` shim.
- System/Legacy: implement DetachCharBlocks() over their allocator and make BlockAllocator private — detachment is the only seam-crossing surface now.
- Legacy: add the Dispose override System already had, closing the leak.
- LogfileReader: six `is`-branches collapse to one DetachCharBlocks() call per site. Legacy now participates uniformly.

Tests migrated off reader.BlockAllocator onto the public DetachCharBlocks() seam.
@Hirogen Hirogen merged commit 9ece117 into Development Jun 25, 2026
1 check passed
@Hirogen Hirogen deleted the closing_the_block_detach_seam_leak branch June 25, 2026 14:16
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.

1 participant