c# - I'm getting a process memory usage using PerformanceCounter. How can i display the memory usage in the same units as in task manager? -
private void backgroundworker1_dowork(object sender, doworkeventargs e) { backgroundworker worker = sender backgroundworker; if ((worker.cancellationpending == true)) { e.cancel = true; } else { while (true) { process[] processes = process.getprocessesbyname("gamecapture"); performancecounter performancecounter = new performancecounter(); performancecounter.categoryname = "process"; performancecounter.countername = "working set"; performancecounter.instancename = processes[0].processname; worker.reportprogress(0, ((uint)performancecounter.nextvalue() / 1024).tostring("n0")); } } } what in program 530.7 mb in task manager same process see around 445.3 mb
why big difference between program , task manager ? should if wanted display in program task manager value ?
working set represents size of pages belonging process. variable shrinks , grows when pages moved page file , when called main memory, respectively. doesn't refer exclusively memory application uses, such shared memory might counted twice in metric. here more info.
working set - private metric looking for. windows task manager uses working set private memory usage metric. doesn't concern page file, accurate representation of impact on physical ram, , doesn't count shared objects twice.
performancecounter performancecounter = new performancecounter(); performancecounter.categoryname = "process"; performancecounter.countername = "working set - private"; performancecounter.instancename = processes[0].processname;
Comments
Post a Comment