Edit

Share via


MemoryCache.CacheMemoryLimit Property

Definition

Gets the amount of memory on the computer, in bytes, that can be used by the cache.

public:
 property long CacheMemoryLimit { long get(); };
public long CacheMemoryLimit { get; }
member this.CacheMemoryLimit : int64
Public ReadOnly Property CacheMemoryLimit As Long

Property Value

The amount of memory in bytes.

Remarks

Important

In .NET Core and .NET 5.0 and later, the CacheMemoryLimit property does not have any effect. The underlying implementation for enforcing this limit is not functional outside of .NET Framework.

In .NET Framework (4.x), if the current instance of the cache exceeds the limit on memory set by the CacheMemoryLimit property, the cache implementation removes cache entries. Each cache instance in the application can use the amount of memory that is specified by the CacheMemoryLimit property. In .NET Core and later, this property returns the value from configuration or constructor parameters but is not enforced.

You can specify the settings for the CacheMemoryLimit property in the application configuration file. Alternatively, they can be passed in the constructor or by a caller when the MemoryCache instance is initialized.

Applies to

See also