MemoryCache.CacheMemoryLimit Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應