Re: max heap usage of a Linux process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 11/13/06, Dan Gary <funkychunkymunky@xxxxxxxxx> wrote:
unless parent is asking about malloc'd space, then mallinfo() or
malloc_stats() might be what they're looking for, memory profiling the
manual way, gotta love it


interesting didn't know that..

though now I have a question about it ..

#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>

int main(){
       char *foo;
       printf("total free space: %d\n",mallinfo().fordblks);
       foo=malloc(500000);
       if(foo){
               printf("successfully allocated!\n");
       } else {
               printf("error allocating!\n");
       }
       printf("arena: %d\n",mallinfo().arena);
       printf("ordblks: %d\n",mallinfo().ordblks);
       printf("max total allocated space: %d\n",mallinfo().usmblks);
       printf("total allocated space: %d\n",mallinfo().uordblks);
       printf("total free space: %d\n",mallinfo().fordblks);

       return 0;
}

outputs:
total free space: 0
successfully allocated!
arena: 0
ordblks: 1
max total allocated space: 0
total allocated space: 0
total free space: 0

If I allocate 50000bytes then it outputs:
total free space: 0
successfully allocated!
arena: 184320
ordblks: 1
max total allocated space: 0
total allocated space: 50008
total free space: 134312

does anyone have an explanation for that?

Markus
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux