aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 7158b45a340..36040f70b2d 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -166,16 +166,16 @@ struct emacs_globals globals;
166 166
167/* Number of bytes of consing done since the last gc. */ 167/* Number of bytes of consing done since the last gc. */
168 168
169EMACS_INT consing_since_gc; 169static EMACS_INT consing_since_gc;
170 170
171/* Similar minimum, computed from Vgc_cons_percentage. */ 171/* Similar minimum, computed from Vgc_cons_percentage. */
172 172
173EMACS_INT gc_relative_threshold; 173static EMACS_INT gc_relative_threshold;
174 174
175/* Minimum number of bytes of consing since GC before next GC, 175/* Minimum number of bytes of consing since GC before next GC,
176 when memory is full. */ 176 when memory is full. */
177 177
178EMACS_INT memory_full_cons_threshold; 178static EMACS_INT memory_full_cons_threshold;
179 179
180/* Nonzero during GC. */ 180/* Nonzero during GC. */
181 181
@@ -5374,6 +5374,18 @@ bounded_number (EMACS_INT number)
5374 return make_number (min (MOST_POSITIVE_FIXNUM, number)); 5374 return make_number (min (MOST_POSITIVE_FIXNUM, number));
5375} 5375}
5376 5376
5377/* Check whether it's time for GC, and run it if so. */
5378
5379void
5380maybe_gc (void)
5381{
5382 if ((consing_since_gc > gc_cons_threshold
5383 && consing_since_gc > gc_relative_threshold)
5384 || (!NILP (Vmemory_full)
5385 && consing_since_gc > memory_full_cons_threshold))
5386 Fgarbage_collect ();
5387}
5388
5377DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", 5389DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",
5378 doc: /* Reclaim storage for Lisp objects no longer needed. 5390 doc: /* Reclaim storage for Lisp objects no longer needed.
5379Garbage collection happens automatically if you cons more than 5391Garbage collection happens automatically if you cons more than