From: Dmitry Antipov Date: Sun, 22 Jul 2012 15:13:50 +0000 (+0400) Subject: Adjust consing_since_gc when objects are explicitly freed. X-Git-Tag: emacs-24.2.90~1101 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0dd6d66d56e7133818db361cc853fd1d00f2714b;p=emacs.git Adjust consing_since_gc when objects are explicitly freed. * alloc.c (GC_DEFAULT_THRESHOLD): New macro. (Fgarbage_collect): Use it. Change minimum to 1/10 of default. (free_cons, free_misc): Subtract object size from consing_since_gc. --- diff --git a/src/ChangeLog b/src/ChangeLog index f0937856559..f689cc20ee0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2012-07-22 Dmitry Antipov + + Adjust consing_since_gc when objects are explicitly freed. + * alloc.c (GC_DEFAULT_THRESHOLD): New macro. + (Fgarbage_collect): Use it. Change minimum to 1/10 of default. + (free_cons, free_misc): Subtract object size from consing_since_gc. + 2012-07-22 Dmitry Antipov Simplify and cleanup markers positioning code. diff --git a/src/alloc.c b/src/alloc.c index 05e676836c5..9f3c2a2ed4b 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -161,6 +161,10 @@ static pthread_mutex_t alloc_mutex; #define GC_STRING_BYTES(S) (STRING_BYTES (S)) +/* Default value of gc_cons_threshold (see below). */ + +#define GC_DEFAULT_THRESHOLD (100000 * sizeof (Lisp_Object)) + /* Global variables. */ struct emacs_globals globals; @@ -2711,6 +2715,7 @@ free_cons (struct Lisp_Cons *ptr) ptr->car = Vdead; #endif cons_free_list = ptr; + consing_since_gc -= sizeof *ptr; total_free_conses++; } @@ -3606,7 +3611,7 @@ free_misc (Lisp_Object misc) XMISCTYPE (misc) = Lisp_Misc_Free; XMISC (misc)->u_free.chain = marker_free_list; marker_free_list = XMISC (misc); - + consing_since_gc -= sizeof (union Lisp_Misc); total_free_markers++; } @@ -5581,8 +5586,8 @@ See Info node `(elisp)Garbage Collection'. */) gc_in_progress = 0; consing_since_gc = 0; - if (gc_cons_threshold < 10000) - gc_cons_threshold = 10000; + if (gc_cons_threshold < GC_DEFAULT_THRESHOLD / 10) + gc_cons_threshold = GC_DEFAULT_THRESHOLD / 10; gc_relative_threshold = 0; if (FLOATP (Vgc_cons_percentage)) @@ -6731,7 +6736,7 @@ init_alloc_once (void) #endif refill_memory_reserve (); - gc_cons_threshold = 100000 * sizeof (Lisp_Object); + gc_cons_threshold = GC_DEFAULT_THRESHOLD; } void