Scenario 3 – large allocations option

This time, we pass the 2 parameter, asking the program to perform larger allocations (greater than MMAP_THRESHOLD):

$ ./malloc_brk_test 2
init_brk = 0x2209000
#: malloc( n) = heap_ptr cur_brk delta
[cur_brk-init_brk]
[...]

3: malloc( 136168) = 0x7f57288cd010 0x222a000 [135168]
Arena 0:
system bytes = 135168
in use bytes = 5792
Total (incl. mmap):
system bytes = 274432
in use bytes = 145056
max mmap regions = 1
max mmap bytes = 139264

4: malloc( 1048576) = 0x7f57287c7010 0x222a000 [135168]
Arena 0:
system bytes = 135168
in use bytes = 5792
Total (incl. mmap):
system bytes = 1327104
in use bytes = 1197728
max mmap regions = 2
max mmap bytes = 1191936

$

(Note that the preceding code we have clipped the output of the first two small allocations and only show the relevant large ones).

Now, we allocate 132 KB (point 3 in the preceding output); some thing to take note of are as follows:

  • The allocations (#3 and #4) are for 132 KB and 1 MB  both above the MMAP_THRESHOLD (value of 128 KB)
  • The (arena 0) heap in-use bytes (5,792) has not changed at all across these two allocations, indicating that heap memory has not been used
  • The max mmap regions and max mmap bytes numbers have changed to positive values (from zero), indicating the use of mmap-ed memory

A couple of remaining scenarios will be examined later.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.197.164