Process Memory Calculation
- Last UpdatedJun 06, 2024
- 1 minute read
Restart of a Windows service is based on the memory of its processes (instances of Windows service). The Client service will calculate the memory of the process.
We use System.Diagonstic.Process to calculate the memory associated with a specific process.
System.Diagonstic.Process has the following properties to get the memory of a process:
-
WorkingSet64: This is a set of memory pages currently visible to the process in physical RAM memory. The working set includes both shared and private data. Shared memory is the read-only memory which is used by the multiple processes. Private memory is the read-write memory used by a specific process.
-
PrivateMemorySize64: Private memory held by the process. It is the read-writable memory which cannot be shared with other processes.
-
VirtualMemorySize64: Total virtual memory allocated by the OS to a process. The value will be more than WorkingSet64 + PrivateMemorySize64.
-
PagedMemorySize64: Amount of paged memory allocated for the associated process.
The Client service can be configured to use any one of the or a combination of the above properties. Combination can be in terms of addition (+), subtraction (-), multiplication(*), and/or division(/).
Syntax for the configuration is as given below.
<MemoryCalcRule Rule="PrivateMemorySize64"/>
<MemoryCalcRule Rule="WorkingSet64 + PrivateMemorySize64"/>
Default is configured as
<MemoryCalcRule Rule="PrivateMemorySize64"/>
-
For a 64-bit machine, 1500MB is the default configured value. This value can be changed in Configuration Settings.