ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/utils/residentMem.c
Revision: 2024
Committed: Tue Feb 15 05:05:33 2005 UTC (19 years, 4 months ago) by gezelter
Content type: text/plain
File size: 611 byte(s)
Log Message:
modifications to estimate memory in use by other processes
autoconf fixes
ps syntax checking
config.h file cleaning

File Contents

# Content
1 #include <config.h>
2 #include <string.h>
3 #include <stdio.h>
4
5 double residentMem () {
6
7 FILE* procresults;
8 char buf[150];
9 char* foo;
10 long int myRSS, totRSS;
11 char* pscommand;
12
13 pscommand = strdup("PS");
14
15 #if PSTYPE == BSD
16 strcat(pscommand, " ax -o rss");
17 #else
18 strcat(pscommand, " -ef -o rss");
19 #endif
20
21 procresults = popen(pscommand, "r");
22
23 totRSS = 0;
24 while (!feof(procresults)) {
25 fgets( buf, 150, procresults);
26 if (!strcmp(buf, " RSS")) continue;
27
28 foo = strtok(buf, " ,;\t");
29 myRSS = atoi(foo);
30 totRSS += myRSS;
31 }
32 pclose(procresults);
33
34 return(totRSS);
35
36 }