malloc.3: NOTES: Add a short discussion of arenas

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2012-03-09 12:32:31 +13:00
parent b084fc293b
commit f1c3fa9757
1 changed files with 19 additions and 1 deletions

View File

@ -25,7 +25,7 @@
.\" Documented MALLOC_CHECK_, Wolfram Gloger (wmglo@dent.med.uni-muenchen.de)
.\" 2007-09-15 mtk: added notes on malloc()'s use of sbrk() and mmap().
.\"
.TH MALLOC 3 2011-09-08 "GNU" "Linux Programmer's Manual"
.TH MALLOC 3 2012-03-09 "GNU" "Linux Programmer's Manual"
.SH NAME
malloc, free, calloc, realloc \- Allocate and free dynamic memory
.SH SYNOPSIS
@ -204,6 +204,24 @@ are unaffected by the
resource limit (see
.BR getrlimit (2)).
To avoid corruption in multithreaded applications,
mutexes are used internally to protect the memory-management
data structures employed by these functions.
In a multithreaded application in which threads simultaneously
allocate and free memory,
there could be contention for these mutexes.
To scalably handle memory allocation in multithreaded applications,
glibc creates additional
.IR "memory allocation arenas"
if mutex contention is detected..
Each arena is a large region of memory that is internally allocated
by the system
(using
.BR brk (2)
or
.BR mmap (2)),
and managed with its own mutexes.
The UNIX 98 standard requires
.BR malloc (),
.BR calloc (),