ImageBufferPool Class
The settings of the process-wide pool of the buffers the library rents for pixels, decoders, encoders and scratch memory.
public static class ImageBufferPoolRemarks
A disposed image, or a finished operation, returns its buffers to the pool, which keeps some of them for the next rentals instead of leaving them to the garbage collector. Retention is bounded per buffer size and in total bytes (ImageBufferPool.MaxRetainedBytes, 32 MiB by default), and buffers larger than 8 MiB are never retained. The retained buffers are not part of any ImageResourceLimits.MaxLiveAllocationBytes budget.
In a memory-constrained container, lower ImageBufferPool.MaxRetainedBytes, or set it to 0 to disable retention: every buffer then goes back to the garbage collector when it is returned. The settings never change the output of an operation. This type is thread-safe.
Properties
| Name | Description |
|---|---|
| MaxRetainedBytes | Gets or sets the maximum number of bytes the pool retains across all buffer sizes. Defaults to ImageBufferPool.DefaultMaxRetainedBytes; 0 disables retention. |
| RetainedBytes | Gets the number of bytes the pool currently retains. |
MaxRetainedBytes
ImageBufferPool.csGets or sets the maximum number of bytes the pool retains across all buffer sizes. Defaults to ImageBufferPool.DefaultMaxRetainedBytes; 0 disables retention.
public static long MaxRetainedBytes { get; set; }Property value
Exceptions
ArgumentOutOfRangeException- The value is negative.
Remarks
Lowering the value releases retained buffers immediately, until the retained bytes fit.
RetainedBytes
ImageBufferPool.csMethods
| Name | Description |
|---|---|
| Trim() | Releases every retained buffer to the garbage collector. Buffers that are in use are not affected. |
Trim()
ImageBufferPool.csReleases every retained buffer to the garbage collector. Buffers that are in use are not affected.
public static void Trim()Constants
| Name | Description |
|---|---|
| DefaultMaxRetainedBytes | The default value of ImageBufferPool.MaxRetainedBytes (32 MiB). |
DefaultMaxRetainedBytes
The default value of ImageBufferPool.MaxRetainedBytes (32 MiB).
public const long DefaultMaxRetainedBytes = 33554432L