diff options
| author | Yuuki Harano | 2020-12-05 20:30:42 +0900 |
|---|---|---|
| committer | Yuuki Harano | 2020-12-05 20:30:42 +0900 |
| commit | da92d5700eff8f628b6306202635a2514eb8b387 (patch) | |
| tree | e632bd68bf0286525e59ce35326986c1cb6f7755 /src/alloc.c | |
| parent | d46a223d8595e8edb67c6361033625797503cacf (diff) | |
| parent | dc39c66d3bb6b1db6af0519659ff154bf6d8a5d1 (diff) | |
| download | emacs-da92d5700eff8f628b6306202635a2514eb8b387.tar.gz emacs-da92d5700eff8f628b6306202635a2514eb8b387.zip | |
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs into feature/pgtk
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c index 1a707cfa57e..51088eb0e77 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -6157,10 +6157,17 @@ where each entry has the form (NAME SIZE USED FREE), where: | |||
| 6157 | - FREE is the number of those objects that are not live but that Emacs | 6157 | - FREE is the number of those objects that are not live but that Emacs |
| 6158 | keeps around for future allocations (maybe because it does not know how | 6158 | keeps around for future allocations (maybe because it does not know how |
| 6159 | to return them to the OS). | 6159 | to return them to the OS). |
| 6160 | |||
| 6160 | However, if there was overflow in pure space, and Emacs was dumped | 6161 | However, if there was overflow in pure space, and Emacs was dumped |
| 6161 | using the 'unexec' method, `garbage-collect' returns nil, because | 6162 | using the 'unexec' method, `garbage-collect' returns nil, because |
| 6162 | real GC can't be done. | 6163 | real GC can't be done. |
| 6163 | See Info node `(elisp)Garbage Collection'. */) | 6164 | |
| 6165 | Note that calling this function does not guarantee that absolutely all | ||
| 6166 | unreachable objects will be garbage-collected. Emacs uses a | ||
| 6167 | mark-and-sweep garbage collector, but is conservative when it comes to | ||
| 6168 | collecting objects in some circumstances. | ||
| 6169 | |||
| 6170 | For further details, see Info node `(elisp)Garbage Collection'. */) | ||
| 6164 | (void) | 6171 | (void) |
| 6165 | { | 6172 | { |
| 6166 | if (garbage_collection_inhibited) | 6173 | if (garbage_collection_inhibited) |
| @@ -6205,6 +6212,30 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 6205 | return CALLMANY (Flist, total); | 6212 | return CALLMANY (Flist, total); |
| 6206 | } | 6213 | } |
| 6207 | 6214 | ||
| 6215 | DEFUN ("garbage-collect-maybe", Fgarbage_collect_maybe, | ||
| 6216 | Sgarbage_collect_maybe, 1, 1, "", | ||
| 6217 | doc: /* Call `garbage-collect' if enough allocation happened. | ||
| 6218 | FACTOR determines what "enough" means here: | ||
| 6219 | If FACTOR is a positive number N, it means to run GC if more than | ||
| 6220 | 1/Nth of the allocations needed to trigger automatic allocation took | ||
| 6221 | place. | ||
| 6222 | Therefore, as N gets higher, this is more likely to perform a GC. | ||
| 6223 | Returns non-nil if GC happened, and nil otherwise. */) | ||
| 6224 | (Lisp_Object factor) | ||
| 6225 | { | ||
| 6226 | CHECK_FIXNAT (factor); | ||
| 6227 | EMACS_INT fact = XFIXNAT (factor); | ||
| 6228 | |||
| 6229 | EMACS_INT since_gc = gc_threshold - consing_until_gc; | ||
| 6230 | if (fact >= 1 && since_gc > gc_threshold / fact) | ||
| 6231 | { | ||
| 6232 | garbage_collect (); | ||
| 6233 | return Qt; | ||
| 6234 | } | ||
| 6235 | else | ||
| 6236 | return Qnil; | ||
| 6237 | } | ||
| 6238 | |||
| 6208 | /* Mark Lisp objects in glyph matrix MATRIX. Currently the | 6239 | /* Mark Lisp objects in glyph matrix MATRIX. Currently the |
| 6209 | only interesting objects referenced from glyphs are strings. */ | 6240 | only interesting objects referenced from glyphs are strings. */ |
| 6210 | 6241 | ||
| @@ -7549,6 +7580,7 @@ N should be nonnegative. */); | |||
| 7549 | defsubr (&Smake_finalizer); | 7580 | defsubr (&Smake_finalizer); |
| 7550 | defsubr (&Spurecopy); | 7581 | defsubr (&Spurecopy); |
| 7551 | defsubr (&Sgarbage_collect); | 7582 | defsubr (&Sgarbage_collect); |
| 7583 | defsubr (&Sgarbage_collect_maybe); | ||
| 7552 | defsubr (&Smemory_info); | 7584 | defsubr (&Smemory_info); |
| 7553 | defsubr (&Smemory_use_counts); | 7585 | defsubr (&Smemory_use_counts); |
| 7554 | #ifdef GNU_LINUX | 7586 | #ifdef GNU_LINUX |