Export (0) Print
Expand All

MemoryCacheElement.CacheMemoryLimitMegabytes Property

.NET Framework 4.6 and 4.5

Gets or sets the maximum memory size, in megabytes, that an instance of a MemoryCache object can grow to.

Namespace:  System.Runtime.Caching.Configuration
Assembly:  System.Runtime.Caching (in System.Runtime.Caching.dll)

[ConfigurationPropertyAttribute("cacheMemoryLimitMegabytes", DefaultValue = )]
[IntegerValidatorAttribute(MinValue = )]
public int CacheMemoryLimitMegabytes { get; set; }

Property Value

Type: System.Int32
The amount of maximum memory size, in megabytes. The default is zero, which indicates that MemoryCache instances manage their own memory based on the amount of memory that is installed on the computer.

The CacheMemoryLimitMegabytes property value represents the cacheMemoryLimitMegabytes configuration attribute in the namedCaches configuration element.

If the cache size exceeds the specified limit, the memory cache implementation removes cache entries.

This property can be set individually in namedCaches elements, with each namedCaches element corresponding to a unique cache configuration.

The settings for the CacheMemoryLimit property can be read from the cacheMemoryLimitMegabytes configuration attribute in the configuration file. Alternatively, the settings can be passed when the MemoryCache class is initialized.

For more information about how to configure the cache, see <namedCaches> Element (Cache Settings).

.NET Framework

Supported in: 4.6, 4.5, 4
Show:
© 2015 Microsoft