Scenario 2 – showing malloc statistics

This time, we pass the 1 parameter, asking it to display malloc(3) statistics as well (achieved using the malloc_stats(3) API):

$ ./malloc_brk_test 1                              init_brk =   0x184e000 #: malloc(       n) =        heap_ptr     cur_brk   delta                                               [cur_brk-init_brk] 0: malloc(       8) =        0x184e670    0x186f000 [135168]Arena 0:system bytes     =     135168in use bytes     =       1664Total (incl. mmap):system bytes     =     135168in use bytes     =       1664max mmap regions =          0max mmap bytes   =          0 1: malloc(    4083) =        0x184e690    0x186f000 [135168]Arena 0:system bytes     =     135168in use bytes     =       5760Total (incl. mmap):system bytes     =     135168in use bytes     =       5760max mmap regions =          0max mmap bytes   =          0 2: malloc(       3) =        0x184f690    0x186f000 [135168]Arena 0:system bytes     =     135168in use bytes     =       5792Total ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.