1. meminfo 사용 관련 application example
링크 : http://wwwcdf.pd.infn.it/MLO/memory.c
|
2. 안드로이드에서 제공되는 오픈소스
링크 : http://www.dre.vanderbilt.edu/~schmidt/android/android-4.0/system/extras/procrank/procrank.c
void print_mem_info() {
char buffer[256];
int numFound = 0;
int fd = open("/proc/meminfo", O_RDONLY);
if (fd < 0) {
printf("Unable to open /proc/meminfo: %s\n", strerror(errno));
return;
}
const int len = read(fd, buffer, sizeof(buffer)-1);
close(fd);
if (len < 0) {
printf("Empty /proc/meminfo");
return;
}
buffer[len] = 0;
static const char* const tags[] = {
"MemTotal:",
"MemFree:",
"Buffers:",
"Cached:",
NULL
};
static const int tagsLen[] = {
9,
8,
8,
7,
0
};
long mem[] = { 0, 0, 0, 0 };
char* p = buffer;
while (*p && numFound < 4) {
int i = 0;
while (tags[i]) {
if (strncmp(p, tags[i], tagsLen[i]) == 0) {
p += tagsLen[i];
while (*p == ' ') p++;
char* num = p;
while (*p >= '0' && *p <= '9') p++;
if (*p != 0) {
*p = 0;
p++;
if (*p == 0) p--;
}
mem[i] = atoll(num);
numFound++;
break;
}
i++;
}
p++;
}
printf("RAM: %ldK total, %ldK free, %ldK buffers, %ldK cached\n",
mem[0], mem[1], mem[2], mem[3]); } |
3. 안드로이드에서 제공되는 메모리 정보 infomation
(커널)
http://egloos.zum.com/rousalome/v/9966593
http://iloveriver.egloos.com/m/6192450
(안드로이드)
http://www.neuromancer.kr/t/145-proc-meminfo/267
http://jaynstory.tistory.com/42
http://blog.naver.com/PostView.nhn?blogId=bl2019&logNo=10186089770
http://droid-tip.blogspot.kr/2013/06/android-adb-shell.html
http://strongslaves.tistory.com/30
http://ecogeo.tistory.com/255
https://elinux.org/Android_Memory_Usage
https://android.googlesource.com/platform/system/core/+/dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0/toolbox/vmstat.c
http://webkebi.zany.kr:9003/board/bView.asp?bCode=91179649&aCode=2511
https://android.googlesource.com/platform/system/extras/+/android-6.0.1_r61/procrank/procrank.c