apple / swift-nio-ssl

TLS Support for SwiftNIO, based on BoringSSL.
https://swiftpackageindex.com/apple/swift-nio-ssl/main/documentation/niossl
Apache License 2.0
385 stars 139 forks source link

Add support for shrinking massive ByteBufferBIOs #443

Closed Lukasa closed 10 months ago

Lukasa commented 10 months ago

Motivation:

ByteBufferBIOs will grow their outbound buffer until flush is called. They will retain their capacity at however large it got to avoid reallocating, as they assume that your write pattern will be fairly consistent.

In some cases this is a bad strategy, because it overcommits data. To allow users to reclaim this data, we can add a configuration option that will shrink the playload on the next write.

Modifications:

Result:

Users can reclaim memory.