O'Reilly logo

Hands-On System Programming with Linux by Kaiwan N Billimoria

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required