Currently calling ArrayPool<T>.Shared.Rent does not guarantee that the returned buffer is zero-inited. While good for performance, this could cause correctness issues in applications, especially those that simply use byte[] xyz = ArrayPool<byte>.Shared.Rent(...) as a drop-in replacement for byte[] xyz = new byte[...].
I propose changing the signature of ArrayPool.Rent(int minimumLength) to ArrayPool.Rent(int minimumLength, bool clearArray = true). Thus the default behavior is to zero-init the returned array, and consumers who want the highest possible performance and don't care about the initial values can pass false for this parameter. (I know we shouldn't default optional arguments to anything other than default(T). Haven't fully reconciled this API design mentally yet.)
Currently calling
ArrayPool<T>.Shared.Rentdoes not guarantee that the returned buffer is zero-inited. While good for performance, this could cause correctness issues in applications, especially those that simply usebyte[] xyz = ArrayPool<byte>.Shared.Rent(...)as a drop-in replacement forbyte[] xyz = new byte[...].I propose changing the signature of
ArrayPool.Rent(int minimumLength)toArrayPool.Rent(int minimumLength, bool clearArray = true). Thus the default behavior is to zero-init the returned array, and consumers who want the highest possible performance and don't care about the initial values can pass false for this parameter. (I know we shouldn't default optional arguments to anything other than default(T). Haven't fully reconciled this API design mentally yet.)