Where is the heap?

I just want to know where (if present!) A bunch of my bash process (pid = 16457) as a result of cat /proc/16457/maps

 0078a000-007a0000 r-xp 00000000 08:02 1319336 /lib/ld-2.3.4.so 007a0000-007a1000 r--p 00015000 08:02 1319336 /lib/ld-2.3.4.so 007a1000-007a2000 rw-p 00016000 08:02 1319336 /lib/ld-2.3.4.so 007a9000-008cf000 r-xp 00000000 08:02 1384495 /lib/tls/libc-2.3.4.so 008cf000-008d1000 r--p 00125000 08:02 1384495 /lib/tls/libc-2.3.4.so 008d1000-008d3000 rw-p 00127000 08:02 1384495 /lib/tls/libc-2.3.4.so 008d3000-008d5000 rw-p 008d3000 00:00 0 008fc000-008fe000 r-xp 00000000 08:02 1319337 /lib/libdl-2.3.4.so 008fe000-008ff000 r--p 00001000 08:02 1319337 /lib/libdl-2.3.4.so 008ff000-00900000 rw-p 00002000 08:02 1319337 /lib/libdl-2.3.4.so 00b27000-00b2a000 r-xp 00000000 08:02 278109 /lib/libtermcap.so.2.0.8 00b2a000-00b2b000 rw-p 00002000 08:02 278109 /lib/libtermcap.so.2.0.8 08047000-080d8000 r-xp 00000000 08:02 902412 /bin/bash 080d8000-080de000 rw-p 00090000 08:02 902412 /bin/bash 080de000-080e3000 rw-p 080de000 00:00 0 09ceb000-09d25000 rw-p 09ceb000 00:00 0 b7d99000-b7d9b000 rw-p b7d99000 00:00 0 b7d9b000-b7da1000 r--s 00000000 08:02 130808 /usr/lib/gconv/gconv-modules.cache b7da1000-b7dd6000 r--s 00000000 08:02 869910 /var/db/nscd/passwd b7dd6000-b7fd6000 r--p 00000000 08:02 101088 /usr/lib/locale/locale-archive b7fd6000-b7fd8000 rw-p b7fd6000 00:00 0 bff07000-c0000000 rw-p bff07000 00:00 0 ffffe000-fffff000 r-xp 00000000 00:00 0 
+4
source share
3 answers

"Unfortunately, most people refer to this line:

 080de000-080e3000 rw-p 080de000 00:00 0 

i.e. This is a memory area created and expanded using syscall brk , right after the main .data and .bss segments.

You can also consider the following as part of the heap:

 09ceb000-09d25000 rw-p 09ceb000 00:00 0 

This seems to be an anonymous mapping created by mmap to serve a large malloc request. Most malloc implementations use mmap for large requests so that they can munmap on free and return the entire memory block to the OS. It also makes calloc lot faster, since you are guaranteed to get pages with a null value this way.

+6
source

In the current version of Linux, the heap is clearly marked as [heap] . Your listing does not display it. Are you sure that it was not by chance that you cut it when copying to your question?

In my shell:

 ~% grep '\[heap' /proc/$$/maps 00bca000-00d2e000 rw-p 00000000 00:00 0 [heap] 
+1
source

Usually the heap is apparently marked with [heap] when calling malloc; however, you will notice that if you continue to grow a bunch with several lines of malloc () code, the range will not grow; however, new blank line entries will be created.

0
source

All Articles