#include <stdio.h>
#include <malloc.h>
int main(int argc, char *argv[])
{
struct mallinfo mem_info;
char *temp;
int i;
if ( argc != 2 )
return 0;
temp = (char*)malloc(atoi(argv[1]));
memset(temp, 0, atoi(argv[1]));
mem_info = mallinfo();
printf("(%d) This is the total size of memory allocated with sbrk by malloc, in bytes.\n", mem_info.arena);
printf("(%d) This is the number of chunks not in use.\n", mem_info.ordblks);
printf("(%d) This field is unused.\n", mem_info.smblks);
printf("(%d) This is the total number of chunks allocated with mmap.\n", mem_info.hblks);
printf("(%d) This is the total size of memory allocated with mmap, in bytes.\n", mem_info.hblkhd);
printf("(%d) This field is unused.\n", mem_info.usmblks);
printf("(%d) This field is unused.\n", mem_info.fsmblks);
printf("(%d) This is the total size of memory occupied by chunks handed out by malloc.\n", mem_info.uordblks);
printf("(%d) This is the total size of memory occupied by free (not in use) chunks.\n", mem_info.fordblks);
printf("(%d) This is the size of the top-most releasable chunk that normally borders the end of the heap.\n", mem_info.keepcost);
return 0;
}
(5828) This is the total size of memory allocated with sbrk by malloc, in bytes.
(1) This is the number of chunks not in use.
(0) This field is unused.
(0) This is the total number of chunks allocated with mmap.
(0) This is the total size of memory allocated with mmap, in bytes.
(0) This field is unused.
(0) This field is unused.
(1036) This is the total size of memory occupied by chunks handed out by malloc.
(4792) This is the total size of memory occupied by free (not in use) chunks.
(4792) This is the size of the top-most releasable chunk that normally borders the end of the heap.
...
구글에서 dumpcode.h 라고 검색해보세요.
------식은이 처------
길이 끝나는 저기엔 아무 것도 없어요. 희망이고 나발이고 아무 것도 없어.
[code:1]#include <stdio.h>#inclu
현재까지 사용된 메모리에 대한 정보를 보여주는 함수 입니다.
ps. man 으로는 안찾아 지네요 ^^;
감사합니다. ^^
좋은 정보 감사합니다. ^^ :D
왜이럴까요
root@testbed:/home/c/poc# gcc -o mem mem.c
root@testbed:/home/c/poc# ./mem
root@testbed:/home/c/poc#
데비안을 쓰는데요 2.2.x 커널..
작동을 안하네요.. 프린터에프가 있는데 =.= 아무런응답이 없음;;
힘내세요.
Re: 왜이럴까요
fflush()
----
LUX ET VERITAS | Just for Fun!
fflush 때문은 아닌거 같은데요
=.= fflush(stdout); 넣어봐도 마찬가지거든요 =.=
힘내세요.
Re: 왜이럴까요
^^;;
소스를 보시면.. 중간에
라고 있는데...;;;
./mem 1024
이런 식으로... 해보시면... ^^;메모리 사용량에 따라 결과 나오는거 볼 수 있도록 하려고 저렇게 했습니다. (귀차니즘으로 에러를 출력 안했더니... ^^;;)
땡큐
^^
힘내세요.
댓글 달기