c# - How do i get memory usage of specific application just like it show in the windows task manager? -


public static void getallmemoryusage(string processname) {     process[] pprocessname = process.getprocessesbyname(processname);//.getcurrentprocess().processname;     var counter = new performancecounter("process", "working set - private", processname);     privatememeory = string.format("private memory: {0}k", counter.nextvalue() / 1024); } 

some problems here:

  1. i have variable process[] pprocessname never use it.

  2. the i'm getting value not same 1 in task manager.

in task manager see 192.6mb in program see 197232. started playing game use application(process) in task manager show: 219.0mb in program 224304.

why it's same values , should process[] pprocessname variable ? how show percentage/s application(process) show in task manager ?

i want method return same value of memory usage , same percentage value in task manager.

yes. can physical amount of memory occupied each through workingset64 property of th process class.

msdn says:

the amount of physical memory, in bytes, allocated associated process.

in case pprocessname array of processes name "processname" can do:

foreach(var process in pprocessname) {   var memorybytes = process.workingset64;   //... } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -