Get virtual and physical memory size

from https://stackoverflow.com/questions/17358345/how-to-get-available-virtual-and-physical-memory-size-under-mono



Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
var physicalMemory = currentProcess.WorkingSet64;
var virtualMemory = currentProcess.PeakVirtualMemorySize64;


from https://docs.microsoft.com/zh-tw/dotnet/api/system.diagnostics.process.workingset64?view=netframework-4.7.2
WorkingSet64
Gets the amount of physical memory, in bytes, allocated for the associated process.

PeakVirtualMemorySize64
Gets the maximum amount of virtual memory, in bytes, used by the associated process.

Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
FileUtil.ConsolLog("physicalMemory=" + currentProcess.WorkingSet64);
FileUtil.ConsolLog("virtualMemory=" + currentProcess.PeakVirtualMemorySize64);


留言

熱門文章