| 1 | gezelter | 2024 | #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 | gezelter | 2026 | char pscommand[150]; | 
| 12 | gezelter | 2024 |  | 
| 13 | gezelter | 2026 | strncpy(pscommand, PSCOMMAND, strlen(PSCOMMAND)); | 
| 14 | gezelter | 2024 |  | 
| 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 |  |  | } |