[git commit] use_less_ram: explain stack and heap

Denys Vlasenko vda.linux at googlemail.com
Fri Apr 22 16:47:00 UTC 2016


commit: https://git.busybox.net/busybox-website/commit/?id=9ad30e40592ba559e3802e3acec247ba4410997a
branch: https://git.busybox.net/busybox-website/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 use_less_ram.html | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/use_less_ram.html b/use_less_ram.html
index d414d81..9a8afbe 100644
--- a/use_less_ram.html
+++ b/use_less_ram.html
@@ -39,15 +39,18 @@ Data, bss and stack pages are never freed, therefore for large,
 and especially for temporary allocations, it's best to use malloc()
 or mmap().
 </p><p>
-[describe stack]
-</p><p>
-[describe heap]
-</p><p>
-</p><p>
-</p><p>
-</p><p>
-</p><p>
-</p><p>
+When process starts executing, two more mappings appear. One is the stack.
+It is usually located ner the top of virtual address space, and contains
+program command line, environment and ELF auxiliary vector.
+This is an anonymouns mapping.
+</p><p>
+Another anonymouns mapping is created by malloc subsystem in libc.
+This mapping is initially empty, but it is a growable and shrinkable
+via the brk(2) system call. Normally it starts right after the last
+page of bss, but kernels configured with address space randomization
+can place it elsewhere.
+Moderately sized malloc requests are served from this area.
+pmap shows it as "[heap]" mapping.
 </p><p>
 You can see these mappings with the following command, where busybox
 shows its own memory map:
@@ -81,7 +84,7 @@ now need one more page.
 This can be fixed if we make GNU linker to use our own linker script
 instead of a built-in one. We will do this by modifying its default script.
 Every busybox build generates a "busybox_unstripped.out" file. Among other
-infromation, it constans a part which says: "using internal linker script:",
+infromation, it contains a part which says "using internal linker script:",
 and the script follows.
 </p><p>
 Cut out the script and put it into a file named "busybox_ldscript".
@@ -147,8 +150,8 @@ to place all formerly-bss variables to data:
 The result of this change is visible in pmap as absense of "[ anon ]" mapping:
 </p><p>
 <pre>
-08048000     856K r-xp  /app/busybox-1.22.1/busybox
-0811e000       8K rw-p  /app/busybox-1.22.1/busybox -- former bss is in here
+08048000     856K r-xp  /bin/busybox
+0811e000       8K rw-p  /bin/busybox -- former bss is in here
 08bbf000       4K rw-p  [heap]
 f77a2000       8K r--p  [vvar]
 f77a4000       8K r-xp  [vdso]
@@ -160,8 +163,8 @@ this has a small speed penalty.
 </p>
 <h4>Use space at the end of bss: FEATURE_USE_BSS_TAIL</h4>
 <p>
-Bss end is usually not page-aligned. There is an unused space in the last page.
-Linker marks its start with the _end symbol.
+The end of bss is usually not page-aligned. There is an unused space in the last page.
+Linker marks that location with the _end symbol.
 </p><p>
 The FEATURE_USE_BSS_TAIL option attempts to use that space for bb_common_bufsiz1[]
 array. If it fits after _end, that space will be used, and COMMON_BUFSIZE


More information about the busybox-cvs mailing list