]> git.eshelyaron.com Git - emacs.git/commitdiff
Adjust consing_since_gc when objects are explicitly freed.
authorDmitry Antipov <dmantipov@yandex.ru>
Sun, 22 Jul 2012 15:13:50 +0000 (19:13 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Sun, 22 Jul 2012 15:13:50 +0000 (19:13 +0400)
* 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.

src/ChangeLog
src/alloc.c

index f093785655959b9a4d33e24f994589c53ff5a93b..f689cc20ee02bae5d88390b44160232c8f3582c3 100644 (file)
@@ -1,3 +1,10 @@
+2012-07-22  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       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  <dmantipov@yandex.ru>
 
        Simplify and cleanup markers positioning code.
index 05e676836c572f7b0d137c81de68581bc315a821..9f3c2a2ed4bfa0a266bf339ae4ee1c50c163f7bc 100644 (file)
@@ -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