Επεξεργασία

Κοινή χρήση μέσω


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

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.

The settings for the CacheMemoryLimit property can be specified in the application configuration file. Alternatively, they can be passed in the constructor when the MemoryCache class is initialized. For more information about how to configure this property, see <namedCaches> Element (Cache Settings). For more information about how to set this value when the MemoryCache class is being initialized, see the MemoryCache method.

MemoryCache does not instantly enforce CacheMemoryLimit each time a new item is added to a MemoryCache instance. The internal heuristics which evicts extra items from the MemoryCache does it gradually and takes into account information from the garbage collector (see Garbage Collection) and other factors such as current cache size and overall system memory pressure. Therefore even though the MemoryCache tries to keep the cache size within the configured CacheMemoryLimit it is possible to temporarily exceed the limit by adding cache items at a very high rate.

Applies to

See also