diff options
| author | Dmitry Antipov | 2012-07-22 19:13:50 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-22 19:13:50 +0400 |
| commit | 0dd6d66d56e7133818db361cc853fd1d00f2714b (patch) | |
| tree | 882087f0fb6ee0cc1e1c1c44c8ed86ec2fa44d38 /src/alloc.c | |
| parent | d36d71df9c550e69d8a469139714a188f221aea8 (diff) | |
| download | emacs-0dd6d66d56e7133818db361cc853fd1d00f2714b.tar.gz emacs-0dd6d66d56e7133818db361cc853fd1d00f2714b.zip | |
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.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 13 |
1 files changed, 9 insertions, 4 deletions
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; | |||
| 161 | 161 | ||
| 162 | #define GC_STRING_BYTES(S) (STRING_BYTES (S)) | 162 | #define GC_STRING_BYTES(S) (STRING_BYTES (S)) |
| 163 | 163 | ||
| 164 | /* Default value of gc_cons_threshold (see below). */ | ||
| 165 | |||
| 166 | #define GC_DEFAULT_THRESHOLD (100000 * sizeof (Lisp_Object)) | ||
| 167 | |||
| 164 | /* Global variables. */ | 168 | /* Global variables. */ |
| 165 | struct emacs_globals globals; | 169 | struct emacs_globals globals; |
| 166 | 170 | ||
| @@ -2711,6 +2715,7 @@ free_cons (struct Lisp_Cons *ptr) | |||
| 2711 | ptr->car = Vdead; | 2715 | ptr->car = Vdead; |
| 2712 | #endif | 2716 | #endif |
| 2713 | cons_free_list = ptr; | 2717 | cons_free_list = ptr; |
| 2718 | consing_since_gc -= sizeof *ptr; | ||
| 2714 | total_free_conses++; | 2719 | total_free_conses++; |
| 2715 | } | 2720 | } |
| 2716 | 2721 | ||
| @@ -3606,7 +3611,7 @@ free_misc (Lisp_Object misc) | |||
| 3606 | XMISCTYPE (misc) = Lisp_Misc_Free; | 3611 | XMISCTYPE (misc) = Lisp_Misc_Free; |
| 3607 | XMISC (misc)->u_free.chain = marker_free_list; | 3612 | XMISC (misc)->u_free.chain = marker_free_list; |
| 3608 | marker_free_list = XMISC (misc); | 3613 | marker_free_list = XMISC (misc); |
| 3609 | 3614 | consing_since_gc -= sizeof (union Lisp_Misc); | |
| 3610 | total_free_markers++; | 3615 | total_free_markers++; |
| 3611 | } | 3616 | } |
| 3612 | 3617 | ||
| @@ -5581,8 +5586,8 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5581 | gc_in_progress = 0; | 5586 | gc_in_progress = 0; |
| 5582 | 5587 | ||
| 5583 | consing_since_gc = 0; | 5588 | consing_since_gc = 0; |
| 5584 | if (gc_cons_threshold < 10000) | 5589 | if (gc_cons_threshold < GC_DEFAULT_THRESHOLD / 10) |
| 5585 | gc_cons_threshold = 10000; | 5590 | gc_cons_threshold = GC_DEFAULT_THRESHOLD / 10; |
| 5586 | 5591 | ||
| 5587 | gc_relative_threshold = 0; | 5592 | gc_relative_threshold = 0; |
| 5588 | if (FLOATP (Vgc_cons_percentage)) | 5593 | if (FLOATP (Vgc_cons_percentage)) |
| @@ -6731,7 +6736,7 @@ init_alloc_once (void) | |||
| 6731 | #endif | 6736 | #endif |
| 6732 | 6737 | ||
| 6733 | refill_memory_reserve (); | 6738 | refill_memory_reserve (); |
| 6734 | gc_cons_threshold = 100000 * sizeof (Lisp_Object); | 6739 | gc_cons_threshold = GC_DEFAULT_THRESHOLD; |
| 6735 | } | 6740 | } |
| 6736 | 6741 | ||
| 6737 | void | 6742 | void |