Unix Programming - Function to display process memory usage

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > December 2007 > Function to display process memory usage





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Function to display process memory usage
Tim Frink

2007-12-25, 1:24 pm

Hi,

is there a C/C++ function to print the current memory
usage (as shown in "top" in column "RES") of this process?

Regards,
Tim
Ivan Novick

2007-12-25, 7:19 pm

On Dec 25, 11:22 am, Tim Frink <plfr...@yahoo.de> wrote:
> Hi,
>
> is there a C/C++ function to print the current memory
> usage (as shown in "top" in column "RES") of this process?


Are you on Linux?

You can try reading the file /proc/meminfo

I believe applications like top must use the /proc (or maybe sysfs?)
filesystem to obtain the information about the system.

Ivan Novick
http://www.0x4849.net
Minimiscience

2007-12-26, 1:39 am

Tim Frink <plfriko@yahoo.de> writes:

>is there a C/C++ function to print the current memory
>usage (as shown in "top" in column "RES") of this process?


If you're using a BSD-derived system, you can try the getrusage(2) function
declared in <sys/resource.h>.

--
You can't write me, I :q!
lg..

2007-12-26, 1:25 pm

On Dec 25, 4:22 pm, Tim Frink <plfr...@yahoo.de> wrote:
> Hi,
>
> is there a C/C++ function to print the current memory
> usage (as shown in "top" in column "RES") of this process?
>
> Regards,
> Tim


you can try with "free"
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com