1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00
2000-06-28  Wolfram Gloger  <wg@malloc.de>

	* malloc/malloc.c (chunk_alloc): If extension of the linear heap
	fails, try mmap_chunk() as a last resort even though n_mmaps_max
	may have been reached.
This commit is contained in:
Ulrich Drepper
2000-06-28 23:28:29 +00:00
parent 5295113f8f
commit 07c35131ad
5 changed files with 1978 additions and 1875 deletions

View File

@ -1872,8 +1872,6 @@ mmap_chunk(size) size_t size;
size_t page_mask = malloc_getpagesize - 1;
mchunkptr p;
if(n_mmaps >= n_mmaps_max) return 0; /* too many regions */
/* For mmapped chunks, the overhead is one SIZE_SZ unit larger, because
* there is no following chunk whose prev_size field could be used.
*/
@ -2930,8 +2928,10 @@ chunk_alloc(ar_ptr, nb) arena *ar_ptr; INTERNAL_SIZE_T nb;
{
#if HAVE_MMAP
/* If big and would otherwise need to extend, try to use mmap instead */
/* If the request is big and there are not yet too many regions,
and we would otherwise need to extend, try to use mmap instead. */
if ((unsigned long)nb >= (unsigned long)mmap_threshold &&
n_mmaps < n_mmaps_max &&
(victim = mmap_chunk(nb)) != 0)
return victim;
#endif
@ -2939,7 +2939,15 @@ chunk_alloc(ar_ptr, nb) arena *ar_ptr; INTERNAL_SIZE_T nb;
/* Try to extend */
malloc_extend_top(ar_ptr, nb);
if ((remainder_size = chunksize(top(ar_ptr)) - nb) < (long)MINSIZE)
{
#if HAVE_MMAP
/* A last attempt: when we are out of address space in the arena,
try mmap anyway, disregarding n_mmaps_max. */
if((victim = mmap_chunk(nb)) != 0)
return victim;
#endif
return 0; /* propagate failure */
}
}
victim = top(ar_ptr);