diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-08-22 06:19:12 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-08-22 06:19:12 +0000 |
commit | e404fb16fc35210219159a446f7c993760a37316 (patch) | |
tree | b111528ec288146613b4cac260bb58372ed47da5 /malloc/malloc.c | |
parent | 376e973ad66993e7b5dbdfd173c399e1af3a1add (diff) | |
download | glibc-e404fb16fc35210219159a446f7c993760a37316.tar.gz glibc-e404fb16fc35210219159a446f7c993760a37316.tar.xz glibc-e404fb16fc35210219159a446f7c993760a37316.zip |
* malloc/malloc.c (DEFAULT_MMAP_THRESHOLD_MAX): For 32-bit
platforms define as 1MB. For 64-bit platforms as 32MB. The lower limit is needed to avoid the exploding of the address space requirement for secondary heaps. * malloc/arena.c (HEAP_MAX_SIZE): Define using DEFAULT_MMAP_THRESHOLD_MAX if it is defined.
Diffstat (limited to 'malloc/malloc.c')
-rw-r--r-- | malloc/malloc.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c index b1f813efbe..7ad26af069 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -259,6 +259,7 @@ #ifdef _LIBC #include <stdio-common/_itoa.h> +#include <bits/wordsize.h> #endif #ifdef __cplusplus @@ -1424,7 +1425,15 @@ int __posix_memalign(void **, size_t, size_t); #endif #ifndef DEFAULT_MMAP_THRESHOLD_MAX -#define DEFAULT_MMAP_THRESHOLD_MAX (8 * 1024 * 1024 * sizeof(long)) + /* For 32-bit platforms we cannot increase the maximum mmap + threshold much because it is also the minimum value for the + maximum heap size and its alignment. Going above 1MB wastes too + much address space. */ +# if __WORDSIZE == 32 +# define DEFAULT_MMAP_THRESHOLD_MAX (1024 * 1024) +# else +# define DEFAULT_MMAP_THRESHOLD_MAX (8 * 1024 * 1024 * sizeof(long)) +# endif #endif /* @@ -2867,6 +2876,7 @@ static Void_t* sYSMALLOc(nb, av) INTERNAL_SIZE_T nb; mstate av; char* mm; /* return value from mmap call*/ + try_mmap: /* Round up size to nearest page. For mmapped chunks, the overhead is one SIZE_SZ unit larger than for normal chunks, because there @@ -2996,6 +3006,9 @@ static Void_t* sYSMALLOc(nb, av) INTERNAL_SIZE_T nb; mstate av; set_foot(old_top, (old_size + 2*SIZE_SZ)); } } + else + /* We can at least try to use to mmap memory. */ + goto try_mmap; } else { /* av == main_arena */ |