diff --git a/src/System.Private.CoreLib/shared/System/Buffers/ConfigurableArrayPool.cs b/src/System.Private.CoreLib/shared/System/Buffers/ConfigurableArrayPool.cs index 6dd30632581..054a38fc602 100644 --- a/src/System.Private.CoreLib/shared/System/Buffers/ConfigurableArrayPool.cs +++ b/src/System.Private.CoreLib/shared/System/Buffers/ConfigurableArrayPool.cs @@ -100,13 +100,13 @@ public override T[] Rent(int minimumLength) // The pool was exhausted for this buffer size. Allocate a new buffer with a size corresponding // to the appropriate bucket. - buffer = new T[_buckets[index]._bufferLength]; + buffer = GC.AllocateUninitializedArray(_buckets[index]._bufferLength); } else { // The request was for a size too large for the pool. Allocate an array of exactly the requested length. // When it's returned to the pool, we'll simply throw it away. - buffer = new T[minimumLength]; + buffer = GC.AllocateUninitializedArray(minimumLength); } if (log.IsEnabled()) @@ -215,7 +215,7 @@ internal Bucket(int bufferLength, int numberOfBuffers, int poolId) // for that slot, in which case we should do so now. if (allocateBuffer) { - buffer = new T[_bufferLength]; + buffer = GC.AllocateUninitializedArray(_bufferLength); var log = ArrayPoolEventSource.Log; if (log.IsEnabled()) diff --git a/src/System.Private.CoreLib/shared/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs b/src/System.Private.CoreLib/shared/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs index 47470715ecf..7369ed8ca6f 100644 --- a/src/System.Private.CoreLib/shared/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs +++ b/src/System.Private.CoreLib/shared/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs @@ -136,13 +136,13 @@ public override T[] Rent(int minimumLength) } // No buffer available. Allocate a new buffer with a size corresponding to the appropriate bucket. - buffer = new T[_bucketArraySizes[bucketIndex]]; + buffer = GC.AllocateUninitializedArray(_bucketArraySizes[bucketIndex]); } else { // The request was for a size too large for the pool. Allocate an array of exactly the requested length. // When it's returned to the pool, we'll simply throw it away. - buffer = new T[minimumLength]; + buffer = GC.AllocateUninitializedArray(minimumLength); } if (log.IsEnabled())