Mercurial > emacs
changeset 17345:4e11e27ce1f1
For glibc's malloc, include <malloc.h> for mallinfo,
mallopt, struct mallinfo, and mallopt constants.
(BYTES_USED): New macro.
(memory_full, emacs_blocked_free): Replace _bytes_used with BYTES_USED.
(emacs_blocked_malloc): Set sbrk padding value for glibc, as is
done with gmalloc.
(allocate_vectorlike, make_uninit_string):
Prevent using mmap for possible large chunks.
(init_alloc_once): Set trim and mmap malloc parms, when using glibc.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 09 Apr 1997 03:59:08 +0000 |
parents | 0178aa2a41e9 |
children | f29f51d8a21f |
files | src/alloc.c |
diffstat | 1 files changed, 39 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alloc.c Wed Apr 09 03:52:47 1997 +0000 +++ b/src/alloc.c Wed Apr 09 03:59:08 1997 +0000 @@ -37,6 +37,10 @@ extern char *sbrk (); +#ifdef DOUG_LEA_MALLOC +#include <malloc.h> +#define __malloc_size_t int +#else /* The following come from gmalloc.c. */ #if defined (__STDC__) && __STDC__ @@ -47,6 +51,7 @@ #endif extern __malloc_size_t _bytes_used; extern int __malloc_extra_blocks; +#endif /* !defined(DOUG_LEA_MALLOC) */ extern Lisp_Object Vhistory_length; @@ -208,12 +213,18 @@ internal_with_output_to_temp_buffer (" *Danger*", malloc_warning_1, val); } +#ifdef DOUG_LEA_MALLOC + #define BYTES_USED (mallinfo ().arena) +#else + #define BYTES_USED _bytes_used +#endif + /* Called if malloc returns zero */ memory_full () { #ifndef SYSTEM_MALLOC - bytes_used_when_full = _bytes_used; + bytes_used_when_full = BYTES_USED; #endif /* The first time we get here, free the spare memory. */ @@ -333,7 +344,7 @@ The code here is correct as long as SPARE_MEMORY is substantially larger than the block size malloc uses. */ && (bytes_used_when_full - > _bytes_used + max (malloc_hysteresis, 4) * SPARE_MEMORY)) + > BYTES_USED + max (malloc_hysteresis, 4) * SPARE_MEMORY)) spare_memory = (char *) malloc (SPARE_MEMORY); __free_hook = emacs_blocked_free; @@ -363,7 +374,11 @@ BLOCK_INPUT; __malloc_hook = old_malloc_hook; - __malloc_extra_blocks = malloc_hysteresis; + #ifdef DOUG_LEA_MALLOC + mallopt (M_TOP_PAD, malloc_hysteresis * 4096); + #else + __malloc_extra_blocks = malloc_hysteresis; + #endif value = (void *) malloc (size); __malloc_hook = emacs_blocked_malloc; UNBLOCK_INPUT; @@ -731,8 +746,16 @@ struct Lisp_Vector *p; allocating_for_lisp = 1; +#ifdef DOUG_LEA_MALLOC + /* Prevent mmap'ing the chunk (which is potentially very large). */ + mallopt (M_MMAP_MAX, 0); +#endif p = (struct Lisp_Vector *)xmalloc (sizeof (struct Lisp_Vector) + (len - 1) * sizeof (Lisp_Object)); +#ifdef DOUG_LEA_MALLOC + /* Back to a reasonable maximum of mmap'ed areas. */ + mallopt (M_MMAP_MAX, 64); +#endif allocating_for_lisp = 0; VALIDATE_LISP_STORAGE (p, 0); consing_since_gc += (sizeof (struct Lisp_Vector) @@ -1180,7 +1203,15 @@ { register struct string_block *new; allocating_for_lisp = 1; +#ifdef DOUG_LEA_MALLOC + /* Prevent mmap'ing the chunk (which is potentially very large). */ + mallopt (M_MMAP_MAX, 0); +#endif new = (struct string_block *) xmalloc (sizeof (struct string_block_head) + fullsize); +#ifdef DOUG_LEA_MALLOC + /* Back to a reasonable maximum of mmap'ed areas. */ + mallopt (M_MMAP_MAX, 64); +#endif allocating_for_lisp = 0; VALIDATE_LISP_STORAGE (new, 0); consing_since_gc += sizeof (struct string_block_head) + fullsize; @@ -2579,6 +2610,11 @@ #endif all_vectors = 0; ignore_warnings = 1; +#ifdef DOUG_LEA_MALLOC + mallopt (M_TRIM_THRESHOLD, 128*1024); /* trim threshold */ + mallopt (M_MMAP_THRESHOLD, 64*1024); /* mmap threshold */ + mallopt (M_MMAP_MAX, 64); /* max. number of mmap'ed areas */ +#endif init_strings (); init_cons (); init_symbol ();