29 lines
621 B
C
29 lines
621 B
C
|
|
// hakmem_tiny_rss.c
|
||
|
|
// Phase 2B-2: RSS Monitoring
|
||
|
|
// Extracted from hakmem_tiny.c (lines 1665-1682)
|
||
|
|
|
||
|
|
#include <stdio.h>
|
||
|
|
#include <stdlib.h>
|
||
|
|
#include <string.h>
|
||
|
|
|
||
|
|
#include "hakmem_tiny_rss_api.h"
|
||
|
|
|
||
|
|
int get_rss_kb_self(void) {
|
||
|
|
FILE* f = fopen("/proc/self/status", "r");
|
||
|
|
if (!f) return 0;
|
||
|
|
char buf[256];
|
||
|
|
int kb = 0;
|
||
|
|
while (fgets(buf, sizeof(buf), f)) {
|
||
|
|
if (strncmp(buf, "VmRSS:", 6) == 0) {
|
||
|
|
char* p = buf;
|
||
|
|
while (*p && (*p < '0' || *p > '9')) {
|
||
|
|
p++;
|
||
|
|
}
|
||
|
|
kb = atoi(p);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
fclose(f);
|
||
|
|
return kb;
|
||
|
|
}
|