-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
One of the benefits of System.IO.Pipelines.Pipe is its ability to be re-used and otherwise conserve memory through usage of ArrayPools internally.
Pipes create BufferSegments internally to store the memory segments it uses, which are further stored in a ReadOnlySequence.
While the buffer segments are re-used through BufferSegmentStack, this is a unique instance on every Pipe and cannot be shared.
This creates a potential issue where if using a pool of Pipes. Each pipe can have its stack grow ("boundlessly") and maybe end up with many un/under-used segments in a long-lived pool.
I would propose that having the buffer segments be responsible for owning/renting the contained array/memory and that the Pipe is only responsible for renting segments.