diff options
| author | Stefan Monnier | 2005-07-13 05:28:37 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-07-13 05:28:37 +0000 |
| commit | 96f077ad7141a3900c623d485cd9a31f6d67acf7 (patch) | |
| tree | d2161b44d16f4aee91a67c88d74a516e53e8063e /src/alloc.c | |
| parent | 090475f391ceb175048e0610bcfabffd8d5a0241 (diff) | |
| download | emacs-96f077ad7141a3900c623d485cd9a31f6d67acf7.tar.gz emacs-96f077ad7141a3900c623d485cd9a31f6d67acf7.zip | |
(gc_cons_combined_threshold, Vgc_cons_percentage): New vars.
(Fgarbage_collect, init_alloc_once): Set gc_cons_combined_threshold.
(syms_of_alloc): Declare gc-cons-percentage.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c index f3c43106087..a8cf897ede2 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -175,6 +175,8 @@ EMACS_INT strings_consed; | |||
| 175 | /* Number of bytes of consing since GC before another GC should be done. */ | 175 | /* Number of bytes of consing since GC before another GC should be done. */ |
| 176 | 176 | ||
| 177 | EMACS_INT gc_cons_threshold; | 177 | EMACS_INT gc_cons_threshold; |
| 178 | EMACS_INT gc_cons_combined_threshold; | ||
| 179 | static Lisp_Object Vgc_cons_percentage; | ||
| 178 | 180 | ||
| 179 | /* Nonzero during GC. */ | 181 | /* Nonzero during GC. */ |
| 180 | 182 | ||
| @@ -4897,6 +4899,26 @@ returns nil, because real GC can't be done. */) | |||
| 4897 | if (gc_cons_threshold < 10000) | 4899 | if (gc_cons_threshold < 10000) |
| 4898 | gc_cons_threshold = 10000; | 4900 | gc_cons_threshold = 10000; |
| 4899 | 4901 | ||
| 4902 | gc_cons_combined_threshold = gc_cons_threshold; | ||
| 4903 | |||
| 4904 | if (FLOATP (Vgc_cons_percentage)) | ||
| 4905 | { /* Set gc_cons_combined_threshold. */ | ||
| 4906 | EMACS_INT total = 0; | ||
| 4907 | EMACS_INT threshold; | ||
| 4908 | total += total_conses * sizeof (struct Lisp_Cons); | ||
| 4909 | total += total_symbols * sizeof (struct Lisp_Symbol); | ||
| 4910 | total += total_markers * sizeof (union Lisp_Misc); | ||
| 4911 | total += total_string_size; | ||
| 4912 | total += total_vector_size * sizeof (Lisp_Object); | ||
| 4913 | total += total_floats * sizeof (struct Lisp_Float); | ||
| 4914 | total += total_intervals * sizeof (struct interval); | ||
| 4915 | total += total_strings * sizeof (struct Lisp_String); | ||
| 4916 | |||
| 4917 | threshold = total * XFLOAT_DATA (Vgc_cons_percentage); | ||
| 4918 | if (threshold > gc_cons_combined_threshold) | ||
| 4919 | gc_cons_combined_threshold = threshold; | ||
| 4920 | } | ||
| 4921 | |||
| 4900 | if (garbage_collection_messages) | 4922 | if (garbage_collection_messages) |
| 4901 | { | 4923 | { |
| 4902 | if (message_p || minibuf_level > 0) | 4924 | if (message_p || minibuf_level > 0) |
| @@ -5986,6 +6008,7 @@ init_alloc_once () | |||
| 5986 | staticidx = 0; | 6008 | staticidx = 0; |
| 5987 | consing_since_gc = 0; | 6009 | consing_since_gc = 0; |
| 5988 | gc_cons_threshold = 100000 * sizeof (Lisp_Object); | 6010 | gc_cons_threshold = 100000 * sizeof (Lisp_Object); |
| 6011 | gc_cons_combined_threshold = gc_cons_threshold; | ||
| 5989 | #ifdef VIRT_ADDR_VARIES | 6012 | #ifdef VIRT_ADDR_VARIES |
| 5990 | malloc_sbrk_unused = 1<<22; /* A large number */ | 6013 | malloc_sbrk_unused = 1<<22; /* A large number */ |
| 5991 | malloc_sbrk_used = 100000; /* as reasonable as any number */ | 6014 | malloc_sbrk_used = 100000; /* as reasonable as any number */ |
| @@ -6017,7 +6040,15 @@ allocated since the last garbage collection. All data types count. | |||
| 6017 | Garbage collection happens automatically only when `eval' is called. | 6040 | Garbage collection happens automatically only when `eval' is called. |
| 6018 | 6041 | ||
| 6019 | By binding this temporarily to a large number, you can effectively | 6042 | By binding this temporarily to a large number, you can effectively |
| 6020 | prevent garbage collection during a part of the program. */); | 6043 | prevent garbage collection during a part of the program. |
| 6044 | See also `gc-cons-percentage'. */); | ||
| 6045 | |||
| 6046 | DEFVAR_LISP ("gc-cons-percentage", &Vgc_cons_percentage, | ||
| 6047 | doc: /* *Portion of the heap used for allocation. | ||
| 6048 | Garbage collection can happen automatically once this portion of the heap | ||
| 6049 | has been allocated since the last garbage collection. | ||
| 6050 | If this portion is smaller than `gc-cons-threshold', this is ignored. */); | ||
| 6051 | Vgc_cons_percentage = make_float (0.1); | ||
| 6021 | 6052 | ||
| 6022 | DEFVAR_INT ("pure-bytes-used", &pure_bytes_used, | 6053 | DEFVAR_INT ("pure-bytes-used", &pure_bytes_used, |
| 6023 | doc: /* Number of bytes of sharable Lisp data allocated so far. */); | 6054 | doc: /* Number of bytes of sharable Lisp data allocated so far. */); |