Well, I am trying to fetch memory (Private working set) for all running instance of Notepad . for example lets say 4 Process of Notepad is running, and now I want total memory consumed by all 4 instance of Notepad.
Till now I have tried for single to get memory (Private working set) for single
Process[] proc = Process.GetProcessesByName(Notepad);
foreach (var kl in proc)
{
idnuml = kl.Id; // fetching pid for Notepad running instance.
}
PerformanceCounter PC = new PerformanceCounter( "Process", "Working Set - Private", InstanceName);
memsize = Convert.ToInt32(PC.NextValue()) / 1024;
I dont know why PerformanceCounter doesn't works with PID. on each iteration it is able to detect Notepad pid for different instance, but at end same Working Set value for all instance.
Please help me . Thanx in advance