I've downloaded the Java Sigar API (http://support.hyperic.com/display/SIGAR/Home) and would like to use it to get memory usage information about different processes which are running.
I've written the following test case to report memory usage of eclipse.exe:
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.ptql.ProcessFinder;
public class SigarTest {
public static void main(String[] args) throws SigarException {
Sigar sigar = new Sigar();
ProcessFinder find = new ProcessFinder(sigar);
long pid = find.findSingleProcess("Exe.Name.ct=eclipse.exe");
System.out.println(sigar.getProcMem(pid));
}
}
Executing this code outputs:
{PageFaults=3017940, Size=4125868032, Resident=608493568}
However, looking at the Windows Resource Monitor, it shows the following stats for eclipse.exe:
Commit (KB): 689,356
Working Set (KB): 594,028
Shareable (KB): 47,332
Private (KB): 546,696
See the following screenshot:
The 4.1GB memory usage reported by Sigar isn't even close to any of the memory stats reported by Resource Monitor.
Why are these so far off?