memory검사

ichshin의 이미지

memory현황을 알수 있는 api가 있을까요? :D

nthroot의 이미지

구글에서 dumpcode.h 라고 검색해보세요.

------식은이 처------
길이 끝나는 저기엔 아무 것도 없어요. 희망이고 나발이고 아무 것도 없어.

lunarainbow의 이미지

#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.

현재까지 사용된 메모리에 대한 정보를 보여주는 함수 입니다.

ps. man 으로는 안찾아 지네요 ^^;

ichshin의 이미지

좋은 정보 감사합니다. ^^ :D

jyj9782의 이미지

root@testbed:/home/c/poc# gcc -o mem mem.c
root@testbed:/home/c/poc# ./mem
root@testbed:/home/c/poc#

데비안을 쓰는데요 2.2.x 커널..

작동을 안하네요.. 프린터에프가 있는데 =.= 아무런응답이 없음;;

힘내세요.

opt의 이미지

jyj9782 wrote:
root@testbed:/home/c/poc# gcc -o mem mem.c
root@testbed:/home/c/poc# ./mem
root@testbed:/home/c/poc#

데비안을 쓰는데요 2.2.x 커널..

작동을 안하네요.. 프린터에프가 있는데 =.= 아무런응답이 없음;;

fflush()

----
LUX ET VERITAS | Just for Fun!

jyj9782의 이미지

=.= fflush(stdout); 넣어봐도 마찬가지거든요 =.=

힘내세요.

lunarainbow의 이미지

opt wrote:
jyj9782 wrote:
root@testbed:/home/c/poc# gcc -o mem mem.c
root@testbed:/home/c/poc# ./mem
root@testbed:/home/c/poc#

데비안을 쓰는데요 2.2.x 커널..

작동을 안하네요.. 프린터에프가 있는데 =.= 아무런응답이 없음;;

fflush()

^^;;

소스를 보시면.. 중간에

if ( argc != 2 ) 
                return 0; 

라고 있는데...;;;

./mem 1024 이런 식으로... 해보시면... ^^;

메모리 사용량에 따라 결과 나오는거 볼 수 있도록 하려고 저렇게 했습니다. (귀차니즘으로 에러를 출력 안했더니... ^^;;)

jyj9782의 이미지

^^

힘내세요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.