aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/alloc.c b/src/alloc.c
index dddfda828e6..3861d87c3d8 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -172,10 +172,16 @@ EMACS_INT misc_objects_consed;
172EMACS_INT intervals_consed; 172EMACS_INT intervals_consed;
173EMACS_INT strings_consed; 173EMACS_INT strings_consed;
174 174
175/* Number of bytes of consing since GC before another GC should be done. */ 175/* Minimum number of bytes of consing since GC before next GC. */
176 176
177EMACS_INT gc_cons_threshold; 177EMACS_INT gc_cons_threshold;
178 178
179/* Similar minimum, computed from Vgc_cons_percentage. */
180
181EMACS_INT gc_relative_threshold;
182
183static Lisp_Object Vgc_cons_percentage;
184
179/* Nonzero during GC. */ 185/* Nonzero during GC. */
180 186
181int gc_in_progress; 187int gc_in_progress;
@@ -4899,6 +4905,24 @@ returns nil, because real GC can't be done. */)
4899 if (gc_cons_threshold < 10000) 4905 if (gc_cons_threshold < 10000)
4900 gc_cons_threshold = 10000; 4906 gc_cons_threshold = 10000;
4901 4907
4908 if (FLOATP (Vgc_cons_percentage))
4909 { /* Set gc_cons_combined_threshold. */
4910 EMACS_INT total = 0;
4911
4912 total += total_conses * sizeof (struct Lisp_Cons);
4913 total += total_symbols * sizeof (struct Lisp_Symbol);
4914 total += total_markers * sizeof (union Lisp_Misc);
4915 total += total_string_size;
4916 total += total_vector_size * sizeof (Lisp_Object);
4917 total += total_floats * sizeof (struct Lisp_Float);
4918 total += total_intervals * sizeof (struct interval);
4919 total += total_strings * sizeof (struct Lisp_String);
4920
4921 gc_relative_threshold = total * XFLOAT_DATA (Vgc_cons_percentage);
4922 }
4923 else
4924 gc_relative_threshold = 0;
4925
4902 if (garbage_collection_messages) 4926 if (garbage_collection_messages)
4903 { 4927 {
4904 if (message_p || minibuf_level > 0) 4928 if (message_p || minibuf_level > 0)
@@ -5988,6 +6012,8 @@ init_alloc_once ()
5988 staticidx = 0; 6012 staticidx = 0;
5989 consing_since_gc = 0; 6013 consing_since_gc = 0;
5990 gc_cons_threshold = 100000 * sizeof (Lisp_Object); 6014 gc_cons_threshold = 100000 * sizeof (Lisp_Object);
6015 gc_relative_threshold = 0;
6016
5991#ifdef VIRT_ADDR_VARIES 6017#ifdef VIRT_ADDR_VARIES
5992 malloc_sbrk_unused = 1<<22; /* A large number */ 6018 malloc_sbrk_unused = 1<<22; /* A large number */
5993 malloc_sbrk_used = 100000; /* as reasonable as any number */ 6019 malloc_sbrk_used = 100000; /* as reasonable as any number */
@@ -6019,7 +6045,15 @@ allocated since the last garbage collection. All data types count.
6019Garbage collection happens automatically only when `eval' is called. 6045Garbage collection happens automatically only when `eval' is called.
6020 6046
6021By binding this temporarily to a large number, you can effectively 6047By binding this temporarily to a large number, you can effectively
6022prevent garbage collection during a part of the program. */); 6048prevent garbage collection during a part of the program.
6049See also `gc-cons-percentage'. */);
6050
6051 DEFVAR_LISP ("gc-cons-percentage", &Vgc_cons_percentage,
6052 doc: /* *Portion of the heap used for allocation.
6053Garbage collection can happen automatically once this portion of the heap
6054has been allocated since the last garbage collection.
6055If this portion is smaller than `gc-cons-threshold', this is ignored. */);
6056 Vgc_cons_percentage = make_float (0.1);
6023 6057
6024 DEFVAR_INT ("pure-bytes-used", &pure_bytes_used, 6058 DEFVAR_INT ("pure-bytes-used", &pure_bytes_used,
6025 doc: /* Number of bytes of sharable Lisp data allocated so far. */); 6059 doc: /* Number of bytes of sharable Lisp data allocated so far. */);