Debugging Dynamic Memory Usage Errors Using HP WDB

can tune malloc() to use a specific ratio of small and ordinary blocks and reduce
heap-fragmentation.
The holding block headers and node blocks are used for the internal data-structure and
book-keeping in malloc(). The sum of the total bytes in holding block headers and node blocks
determines the efficiency of malloc(). The memory allocator is more efficient when it uses less
memory for the internal data-structure and bookkeeping.
Following is a sample output of the info heap process command:
(gdb) info heap process
Total space in arenas: 4657088
Number of bytes in free small blocks: 69216
Number of bytes in used small blocks: 199584
Number of bytes in free ordinary blocks: 2480
Number of bytes in used ordinary blocks: 4375600
Number of bytes in holding block header: 912
Number of small blocks: 3500
Number of ordinary blocks: 9
Number of holding blocks: 0
Number of free ordinary blocks: 1
Number of free small blocks: 388
SBA parmas
enabled: 1
maxfast: 512
numblks: 100
grain: 16
enabled: 0
cache
miss: 0
bucketsize: 0
buckets: 0
retirement: 0
Exec type: SHARE_MAGIC
Analyzing the info heap arenas output
The info heap arenas command displays the memory-usage statistics for the specified arena.
You can analyze the memory-usage statistics of all the arenas to determine if there is an imbalance
in memory-usage across the arenas. For example, if there are many free blocks in an arena and
these blocks are not used by threads from another arena, you can tune the memory-usage to
optimize the performance.
The info heap arenas <arena_id> blocks displays the details of all the blocks in the
given arena in an increasing order of addresses. You can analyze the size of the blocks in the
increasing order of block-addresses to detect heap-fragmentation. For example, you can suspect
heap fragmentation if two large free blocks are separated by a small used block.
Following is a sample output of the info heap arenas command:
(gdb) info heap arenas
num_arenas: 1
expansion: 4096
Arena ID: 0
Total number of blocks in arena: 47
Start address: 0x4001003c
Ending address: 0x40480ffc
Total space: 4657088
Number of bytes in free small blocks: 69216
Number of bytes in used small blocks: 199584
Number of bytes in free ordinary blocks: 2480
Number of bytes in used ordinary blocks: 4375600
24