How can I get the available RAM or memory used by the application?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
In addition to @JesperFyhrKnudsen's answer and @MathiasLykkegaardLorenzen's comment, you'd better
dispose
the returnedProcess
after using it.So, In order to dispose the
Process
, you could wrap it in ausing
scope or callingDispose
on the returned process (proc
variable).using
scope:Or
Dispose
method:Now you could use the
memory
variable which is converted to Megabyte.You might want to check the GC.GetTotalMemory method.
It retrieves the number of bytes currently thought to be allocated by the garbage collector.
For the complete system you can add the Microsoft.VisualBasic Framework as a reference;
You can use:
To get the current process and use:
To get the private memory usage. For more information look at this link.
Look here for details.
If you get value as 0 it need to call
NextValue()
twice. Then it gives the actual value of CPU usage. See more details here.System.Environment has WorkingSet. If you want a lot of details there is System.Diagnostics.PerformanceCounter, but it will be a bit more effort to setup.