GC.AllocateUninitializedArray<T>(Int32, Boolean) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Allocates an array while skipping zero-initialization, if possible.
public static T[] AllocateUninitializedArray<T> (int length, bool pinned = false);
static member AllocateUninitializedArray : int * bool -> 'T[]
Public Shared Function AllocateUninitializedArray(Of T) (length As Integer, Optional pinned As Boolean = false) As T()
Type Parameters
- T
Specifies the type of the array element.
Parameters
- length
- Int32
Specifies the length of the array.
- pinned
- Boolean
Specifies whether the allocated array must be pinned.
Returns
An array object with uninitialized memory.
Remarks
If pinned is set to true
, T
must not be a reference type or a type that contains object references.
Skipping zero-initialization is a security risk. The unitialized array can contain invalid valuetype instances or sensitive information created by other parts of the application. The code operating on unitialized arrays should be heavily scrutinized to ensure that the unitialized data is never read.
Skipping zero-initialization using this API only has a material performance benefit for large arrays, such as buffers of several kilobytes or more.
Applies to
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示