Skip to main content

The MemoryMonitorHook class


Describes the MemoryMonitorHook class that monitors memory usage.

The MemoryMonitorHook class monitors memory usage by using the Process -> Private Bytes counter, and it is enabled by default in a Sitecore installation. If the value of the counter exceeds a specified threshold, a warning message is added to the log files, similar to this:

ManagedPoolThread #4 00:00:34 WARN  Memory usage exceeded the MemoryMonitor threshold.
ManagedPoolThread #4 00:00:34 WARN  Memory usage: 2,863,460,352

A warning message does not necessarily mean that there is an issue. The default threshold value is 2G. If the Sitecore application does not have other issues, you can increase the threshold value. A good starting point is to set the threshold at 85% of actual physical memory, for example 14GB for a system with 16 GB of RAM.

The MemoryMonitorHook class is configured in the Sitecore.config file, and you can change the behavior by patching the configuration. The following is the default configuration:

<hook type="Sitecore.Diagnostics.MemoryMonitorHook, Sitecore.Kernel">
    <param desc="Threshold">2GB</param>
    <param desc="Check interval">00:00:05</param>
    <param desc="Minimum time between log entries">00:01:00</param>




When the Sitecore application uses this amount, or more, of memory, a log message is written. You can specify a number and a scale (KB, MB, GB). The defautlt value is 2GB.

Check interval

Specifies the time span between memory checks.

Minimum time between log entries

Specifies the minimum time span between each log entry.


If true, the class tries to clear caches when the threshold of memory use is exceeded. The default is false.


If true, the class tries to collect garbage when the threshold of memory use is exceeded. The default is false.


If true, Sitecore increases the cache load factor and this reduces the number of entities in the cache. This in turn reduces the memory use. The default is false.


If you specify the Check interval setting as 00:00:00, the hook is effectively disabled.

Only enable the ClearCaches, GarbageCollect, and AdjustLoadFactor options for mitigating errors or as part of troubleshooting. When any of these options is enabled, system performance is impacted. If you have consistent problems with memory usage, you must try and find the underlying problem. A starting point is:

  • Cache sizes might not be set to the optimal values.

  • There is a memory leak in some component.

  • You have a bulk operation that uses large amounts of data.