แก้ไข

แชร์ผ่าน


JsonSerializerOptions.DefaultBufferSize Property

Definition

Gets or sets the default buffer size, in bytes, to use when creating temporary buffers.

public:
 property int DefaultBufferSize { int get(); void set(int value); };
public int DefaultBufferSize { get; set; }
member this.DefaultBufferSize : int with get, set
Public Property DefaultBufferSize As Integer

Property Value

The default buffer size in bytes.

Exceptions

The buffer size is less than 1.

This property was set after serialization or deserialization has occurred.

Remarks

The default buffer size, in bytes, is 16,384. For most workloads, the default size is a reasonable amount of JSON to buffer while reading from a stream or writing to a stream. That is, it performs well without creating objects on the Large Object Heap for the Garbage Collector (GC) to track. In non-streaming scenarios, increasing the default buffer size could improve performance for large JSON strings or UTF-8 byte arrays. We recommend that you leave this value unchanged unless changing it makes an observable difference in performance.

Applies to