From 1e1f3e30efd650af9d995575ce23c585aaeb6e78 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 12 Sep 2023 14:06:54 -0400 Subject: [PATCH] * src/alloc.c (garbage_collect): Run `post-gc-hook` later (bug#65700) --- etc/NEWS | 2 ++ src/alloc.c | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 29d44a622cb..c146f464585 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -831,6 +831,8 @@ the file listing's performance is still optimized. * Incompatible Lisp Changes in Emacs 30.1 +** 'post-gc-hook' runs after updating 'gcs-done' and `'gcs-elapsed'. + --- ** The escape sequence '\x' not followed by hex digits is now an error. Previously, '\x' without at least one hex digit denoted character code diff --git a/src/alloc.c b/src/alloc.c index c0086a70fc1..fbb1c6ed6c3 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -6595,13 +6595,6 @@ garbage_collect (void) image_prune_animation_caches (false); #endif - if (!NILP (Vpost_gc_hook)) - { - specpdl_ref gc_count = inhibit_garbage_collection (); - safe_run_hooks (Qpost_gc_hook); - unbind_to (gc_count, Qnil); - } - /* Accumulate statistics. */ if (FLOATP (Vgc_elapsed)) { @@ -6620,6 +6613,13 @@ garbage_collect (void) if (tot_after < tot_before) malloc_probe (min (tot_before - tot_after, SIZE_MAX)); } + + if (!NILP (Vpost_gc_hook)) + { + specpdl_ref gc_count = inhibit_garbage_collection (); + safe_run_hooks (Qpost_gc_hook); + unbind_to (gc_count, Qnil); + } } DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", -- 2.39.5