// I used this in AGX Xavier
#define MEMINFO "/proc/meminfo"
void printMem()
{
char cmd[1024];
int nMemTot =0;
int nMemAva =0;
// sprintf(cmd, "/proc/%d/status", getpid());
sprintf(cmd, "/proc/meminfo");
FILE* fp = fopen(MEMINFO, "r");
if(fp == NULL) return;
while(fgets(cmd, 1024, fp) != NULL) {
if(strstr(cmd, "MemTotal")) {
char t[32];
char size[32];
sscanf(cmd, "%s%s", t, size);
nMemTot = atoi(size);
}
else if(strstr(cmd, "MemAvailable")) {
char t[32];
char size[32];
sscanf(cmd, "%s%s", t, size);
nMemAva = atoi(size);
break;
}
}
fclose(fp);
printf("+ nMemTot: %dkB, nMemAva: %dkB\n",nMemTot, nMemAva);
printf("+ nMemSub: %dkB (=%dMB)\n",nMemTot-nMemAva,(nMemTot-nMemAva)/1024);
}
'Linux' 카테고리의 다른 글
Asynchronous IO Read (Direct I/O) (0) | 2022.05.19 |
---|---|
Checking the cudnn 8.x version (0) | 2021.03.29 |
Linux Vim Setting (.vimrc) (0) | 2020.12.14 |
ImportError: dynamic module does not define module export function (PyInit_cv_bridge_boost) in Xavier AGX (0) | 2020.10.20 |
Find python, cuda code with ctags, cscope (0) | 2020.10.19 |