LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 11-08-2006, 12:24 PM   #1
gearoid_murphy
Member
 
Registered: Mar 2006
Location: Ireland
Distribution: Debian Etch
Posts: 72

Rep: Reputation: 18
getrusage and process memory usage


hello,
I'm using getrusage to tell me how much stack space I'm using as I go through a series of recursive calls. Heres the code :

struct rusage usage ;
if(getrusage(RUSAGE_CHILDREN, &usage) != 0)
{
cout<<"getrusage failed"<<endl ;
exit(0);
}

cout<<"Shared Memory = "<<usage.ru_ixrss<<endl ;
cout<<"Unshared Data Size = "<<usage.ru_idrss<<endl ;
cout<<"Unshared Stack Size = "<<usage.ru_isrss<<endl ;

However each of the outputs only produces a zero. The program I'm running will use well over 2 gigs of ram (sometimes more...argh!). I'm trying to eliminate superfluous variables by this kind if analysis.

Can anyone tell me why getrusage isn't detecting the stack space I'm using and / or alternative methods of extracting the info I'm looking for.

Cheers,
Gearoid
 
Old 11-08-2006, 02:11 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
man getrusage:
Quote:
The above struct was taken from BSD 4.3 Reno. Not all fields are meaningful under Linux. Right now (Linux 2.4, 2.6) only the fields ru_utime, ru_stime, ru_minflt, ru_majflt, and ru_nswap are maintained.
PS:
Perhaps you can try looking in the proc virtual directory, under /proc/<PID>/status:

http://redhat.activeventure.com/9/re...rectories.html

Last edited by paulsm4; 11-08-2006 at 02:22 PM.
 
Old 11-09-2006, 05:33 AM   #3
gearoid_murphy
Member
 
Registered: Mar 2006
Location: Ireland
Distribution: Debian Etch
Posts: 72

Original Poster
Rep: Reputation: 18
many thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to programmatically monitor a process memory usage? thanhvn Programming 14 02-20-2009 02:15 AM
how to show the memory usage per process ty263 Linux - General 3 09-12-2008 07:36 AM
how to programmatically monitor a process memory usage? thanhvn Linux - Software 1 11-15-2005 09:44 PM
about displaying process memory usage maginotjr Slackware 2 09-13-2005 12:43 PM
Process memory usage wombat53 Linux - Newbie 5 07-21-2005 08:42 PM


All times are GMT -5. The time now is 05:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration