GCMemoryInfo.MemoryLoadBytes 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 physical memory load when the last garbage collection occurred.
public:
property long MemoryLoadBytes { long get(); };
public long MemoryLoadBytes { get; }
member this.MemoryLoadBytes : int64
Public ReadOnly Property MemoryLoadBytes As Long
Property Value
The physical memory load, in bytes, when the last garbage collection occurred.
Remarks
When a process is not running in a container or running in a container without a memory limit:
- On Windows, the MemoryLoadBytes is obtained from the MEMORYSTATUS structure in bytes divided by the total physical memory.
- On Linux, the MemoryLoadBytes is obtained from reading the MemAvailable field from /proc/meminfo
divided by the total physical memory.
When a process is running in a container with a memory limit or when cgroup limits are set:
- On Windows, the MemoryLoadBytes is obtained from the Working Set Size field in the PROCESS_MEMORY_COUNTERS structure in bytes divided by the memory limit.
- On Linux, the MemoryLoadBytes is obtained from the used physical memory via the CGroup Memory Usage file from memory.usage_in_bytes
for CGroups v1 and memory.current
for CGroups v2 divided by the memory limit. The cgroup limits don't necessarily mean there is a container. You can use cgroup to set limits on a regular process.
On Linux, when there is no cgroup enabled, the used physical memory is read from the /proc/statm
file, which provides the process resident set size.
On Linux, the virtual memory load is also used if the virtual memory rlimit is set and if the load is larger than the physical memory load.
Data is only brought into physical memory on first touch. If you allocated a big object but haven't actually used it, most of its memory isn't in physical memory. In this case, the allocation won't affect the memory load significantly.