| 1 |
|
#include <config.h> |
| 2 |
|
#include <string.h> |
| 3 |
|
#include <stdio.h> |
| 4 |
+ |
#include <stdlib.h> |
| 5 |
+ |
#ifdef __sgi |
| 6 |
+ |
#include <unistd.h> |
| 7 |
+ |
#endif |
| 8 |
|
|
| 9 |
+ |
/* |
| 10 |
+ |
* returns an estimate of the resident memory size in kB |
| 11 |
+ |
*/ |
| 12 |
|
double residentMem () { |
| 13 |
|
|
| 14 |
|
FILE* procresults; |
| 16 |
|
char* foo; |
| 17 |
|
long int myRSS, totRSS; |
| 18 |
|
char pscommand[150]; |
| 19 |
+ |
char* psPath; |
| 20 |
|
|
| 21 |
< |
strncpy(pscommand, PSCOMMAND, strlen(PSCOMMAND)); |
| 21 |
> |
STR_DEFINE(psPath, PSCOMMAND ); |
| 22 |
> |
|
| 23 |
> |
|
| 24 |
> |
strncpy(pscommand, psPath, strlen(psPath)+1); |
| 25 |
|
|
| 26 |
< |
#if PSTYPE == BSD |
| 26 |
> |
#ifdef PSTYPE_IS_BSD |
| 27 |
|
strcat(pscommand, " ax -o rss"); |
| 28 |
|
#else |
| 29 |
+ |
#ifdef PSTYPE_IS_POSIX |
| 30 |
|
strcat(pscommand, " -ef -o rss"); |
| 31 |
+ |
#else |
| 32 |
+ |
printf("Unknown ps syntax!\n"); |
| 33 |
|
#endif |
| 34 |
+ |
#endif |
| 35 |
|
|
| 36 |
+ |
printf("doing %s\n", pscommand); |
| 37 |
+ |
|
| 38 |
|
procresults = popen(pscommand, "r"); |
| 39 |
|
|
| 40 |
|
totRSS = 0; |
| 48 |
|
} |
| 49 |
|
pclose(procresults); |
| 50 |
|
|
| 51 |
+ |
#ifdef __sgi |
| 52 |
+ |
|
| 53 |
+ |
|
| 54 |
+ |
totRSS *= getpagesize() / 1024; |
| 55 |
+ |
#endif |
| 56 |
+ |
|
| 57 |
+ |
|
| 58 |
+ |
totRSS *= 1024; |
| 59 |
|
return(totRSS); |
| 60 |
|
|
| 61 |
|
} |