I'm trying to obtain information on memory utilization for a process. I am using ProcMem and have some questions. I am using SIGAR release 1.6 on OSX 10.5.5, JDK 1.5.0_16
The first question is correlating the values returned from ProcMem to what the system calls tell me. Comparing the Mac Activity Monitor, top and SIGAR ProcMem shows me the following:
Mac Activity Monitor
Real Memory : 34.56 MB
Virtual Memory : 487 MB
Shared Memory : 14.93 MB
Private Memory : 42.75 MB
PID COMMAND RPRVT RSHRD RSIZE VSIZE
10308 java 43M 13M 35M 487M
ProcMem.getResident() : 34.5 MB (real memory)
ProcMem.getShare() : -1 (shared memory)
ProcMem.getSize() : 1,055.85 MB (virtual memory)
>From this I can see that shared memory is not supported on OSX, but I am confused with what ProcMem.getSize() returns. It doesnt seem to match up with what the system utilities are telling me. Can someone elaborate as to what the returned value for ProcMem.getSize() maps to?
Also, I am trying to determine the memory utilization for a process. What would I use to determine the amount of heap allocated and heap used? I can do this for Java with JMX calls, but I would like to see if something can also be done for non-Java processes. Is this possible?
I opened a couple of tickets here..
getSize() - http://jira.hyperic.com/browse/SIGAR-123
Short story is there is some logic needed beyond the osx API call to get the value you see in the Activity Monitor.. I checked in a fix, are you setup to compile sigar from source?
I also opened one for getShare(): http://jira.hyperic.com/browse/SIGAR-124
If you follow the source in the link there, you'll see the shared memory value as seen in the system utils doesn't directly correlate to system API call. I'll see about revisiting that soon.
As for the heap, I believe the OS calls (kernel-land) can only tell what's been allocated (resident size). It's up to the user-land app (e.g. JVM) to indicate which portion of the heap is "used".
I tried building sigar and ran across a problem. The build fails telling me libproc.h cant be found. I ran ant with the debug flag and I see this invocation to gcc:
gcc -Wall -O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -mmacosx-version-min=10.3 -c ...
I have libproc.h in /Developer/SDKs/MacOSX10.5sdk, and also the architecture is intel (not sure if that matters?). I changed line 29 in jni-build.xml, setting uni.sdk.version to 5 and the build worked okay.