at least on linux:

get the process id,

then open /proc/$processid/status

and 'grep' out VmRSS which i believe is the resident memory usage of the
process.

you can do this in just about any language since you are really just opening
a file and reading some info out of it.

anyway, this enough for you to go google with.

Josh Coates
http://www.jcoates.org

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Michael Torrie
Sent: Wednesday, September 08, 2004 10:00 PM
To: BYU Unix Users Group
Subject: Re: [uug] getting memory usage


On Wed, 2004-09-08 at 21:51, Joel Self wrote:
> So I need to be able to get the memory usage of a process. Does anyone
> know of a function in C (or any other way) that does this (besides
> getrusage since getrusage doesn't actually do much).  The function
> needs to work in at least in linux and in OSX .

There is no standard way of doing this.  Your best bet is
platform-specific, like checking numbers in /proc.  I don't know of any
programmatic way to do this, mainly because with the VM's in modern OS's
your app gets the entire address space (4 GB on x86), and the VM
invisibly fills requests for memory pages within that entire range.
There are libraries out there that abstract process management apis.
Perhaps something like that might help you.

>
> -Joel Self
>
> ____________________
> BYU Unix Users Group
> http://uug.byu.edu/
> ___________________________________________________________________
> List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
--
Michael Torrie <[EMAIL PROTECTED]>

____________________
BYU Unix Users Group
http://uug.byu.edu/
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list


____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to