mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-02-06 20:49:33 +00:00
* src/alloc.c (Fgarbage_collect_maybe): New function
This commit is contained in:
parent
27af17b9ee
commit
39915c7084
2
etc/NEWS
2
etc/NEWS
@ -1828,6 +1828,8 @@ ledit.el, lmenu.el, lucid.el and old-whitespace.el.
|
||||
|
||||
* Lisp Changes in Emacs 28.1
|
||||
|
||||
** New function `garbage-collect-maybe` to trigger GC early
|
||||
|
||||
---
|
||||
** 'defvar' detects the error of defining a variable currently lexically bound.
|
||||
Such mixes are always signs that the outer lexical binding was an
|
||||
|
25
src/alloc.c
25
src/alloc.c
@ -6209,6 +6209,30 @@ For further details, see Info node `(elisp)Garbage Collection'. */)
|
||||
return CALLMANY (Flist, total);
|
||||
}
|
||||
|
||||
DEFUN ("garbage-collect-maybe", Fgarbage_collect_maybe,
|
||||
Sgarbage_collect_maybe, 1, 1, "",
|
||||
doc: /* Call `garbage-collect' if enough allocation happened.
|
||||
FACTOR determines what "enough" means here:
|
||||
If FACTOR is a positive number N, it means to run GC if more than
|
||||
1/Nth of the allocations needed to trigger automatic allocation took
|
||||
place.
|
||||
Therefore, as N gets higher, this is more likely to perform a GC.
|
||||
Returns non-nil if GC happened, and nil otherwise. */)
|
||||
(Lisp_Object factor)
|
||||
{
|
||||
CHECK_FIXNAT (factor);
|
||||
EMACS_INT fact = XFIXNAT (factor);
|
||||
|
||||
EMACS_INT since_gc = gc_threshold - consing_until_gc;
|
||||
if (fact >= 1 && since_gc > gc_threshold / fact)
|
||||
{
|
||||
garbage_collect ();
|
||||
return Qt;
|
||||
}
|
||||
else
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
/* Mark Lisp objects in glyph matrix MATRIX. Currently the
|
||||
only interesting objects referenced from glyphs are strings. */
|
||||
|
||||
@ -7553,6 +7577,7 @@ N should be nonnegative. */);
|
||||
defsubr (&Smake_finalizer);
|
||||
defsubr (&Spurecopy);
|
||||
defsubr (&Sgarbage_collect);
|
||||
defsubr (&Sgarbage_collect_maybe);
|
||||
defsubr (&Smemory_info);
|
||||
defsubr (&Smemory_use_counts);
|
||||
#ifdef GNU_LINUX
|
||||
|
@ -3798,6 +3798,7 @@ flush_stack_call_func (void (*func) (void *arg), void *arg)
|
||||
|
||||
extern void garbage_collect (void);
|
||||
extern void maybe_garbage_collect (void);
|
||||
extern bool maybe_garbage_collect_eagerly (EMACS_INT factor);
|
||||
extern const char *pending_malloc_warning;
|
||||
extern Lisp_Object zero_vector;
|
||||
extern EMACS_INT consing_until_gc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user