comparison src/alloc.c @ 64267:5c7cbbd6dbb4

(gc_cons_combined_threshold, Vgc_cons_percentage): New vars. (Fgarbage_collect, init_alloc_once): Set gc_cons_combined_threshold. (syms_of_alloc): Declare gc-cons-percentage.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 13 Jul 2005 05:28:37 +0000
parents a8fa7c632ee4
children ce14666827c6
comparison
equal deleted inserted replaced
64266:a634aa374675 64267:5c7cbbd6dbb4
173 EMACS_INT strings_consed; 173 EMACS_INT strings_consed;
174 174
175 /* Number of bytes of consing since GC before another GC should be done. */ 175 /* Number of bytes of consing since GC before another GC should be done. */
176 176
177 EMACS_INT gc_cons_threshold; 177 EMACS_INT gc_cons_threshold;
178 EMACS_INT gc_cons_combined_threshold;
179 static Lisp_Object Vgc_cons_percentage;
178 180
179 /* Nonzero during GC. */ 181 /* Nonzero during GC. */
180 182
181 int gc_in_progress; 183 int gc_in_progress;
182 184
4894 gc_in_progress = 0; 4896 gc_in_progress = 0;
4895 4897
4896 consing_since_gc = 0; 4898 consing_since_gc = 0;
4897 if (gc_cons_threshold < 10000) 4899 if (gc_cons_threshold < 10000)
4898 gc_cons_threshold = 10000; 4900 gc_cons_threshold = 10000;
4901
4902 gc_cons_combined_threshold = gc_cons_threshold;
4903
4904 if (FLOATP (Vgc_cons_percentage))
4905 { /* Set gc_cons_combined_threshold. */
4906 EMACS_INT total = 0;
4907 EMACS_INT threshold;
4908 total += total_conses * sizeof (struct Lisp_Cons);
4909 total += total_symbols * sizeof (struct Lisp_Symbol);
4910 total += total_markers * sizeof (union Lisp_Misc);
4911 total += total_string_size;
4912 total += total_vector_size * sizeof (Lisp_Object);
4913 total += total_floats * sizeof (struct Lisp_Float);
4914 total += total_intervals * sizeof (struct interval);
4915 total += total_strings * sizeof (struct Lisp_String);
4916
4917 threshold = total * XFLOAT_DATA (Vgc_cons_percentage);
4918 if (threshold > gc_cons_combined_threshold)
4919 gc_cons_combined_threshold = threshold;
4920 }
4899 4921
4900 if (garbage_collection_messages) 4922 if (garbage_collection_messages)
4901 { 4923 {
4902 if (message_p || minibuf_level > 0) 4924 if (message_p || minibuf_level > 0)
4903 restore_message (); 4925 restore_message ();
5984 gcprolist = 0; 6006 gcprolist = 0;
5985 byte_stack_list = 0; 6007 byte_stack_list = 0;
5986 staticidx = 0; 6008 staticidx = 0;
5987 consing_since_gc = 0; 6009 consing_since_gc = 0;
5988 gc_cons_threshold = 100000 * sizeof (Lisp_Object); 6010 gc_cons_threshold = 100000 * sizeof (Lisp_Object);
6011 gc_cons_combined_threshold = gc_cons_threshold;
5989 #ifdef VIRT_ADDR_VARIES 6012 #ifdef VIRT_ADDR_VARIES
5990 malloc_sbrk_unused = 1<<22; /* A large number */ 6013 malloc_sbrk_unused = 1<<22; /* A large number */
5991 malloc_sbrk_used = 100000; /* as reasonable as any number */ 6014 malloc_sbrk_used = 100000; /* as reasonable as any number */
5992 #endif /* VIRT_ADDR_VARIES */ 6015 #endif /* VIRT_ADDR_VARIES */
5993 } 6016 }
6015 allocated since the last garbage collection. All data types count. 6038 allocated since the last garbage collection. All data types count.
6016 6039
6017 Garbage collection happens automatically only when `eval' is called. 6040 Garbage collection happens automatically only when `eval' is called.
6018 6041
6019 By binding this temporarily to a large number, you can effectively 6042 By binding this temporarily to a large number, you can effectively
6020 prevent garbage collection during a part of the program. */); 6043 prevent garbage collection during a part of the program.
6044 See also `gc-cons-percentage'. */);
6045
6046 DEFVAR_LISP ("gc-cons-percentage", &Vgc_cons_percentage,
6047 doc: /* *Portion of the heap used for allocation.
6048 Garbage collection can happen automatically once this portion of the heap
6049 has been allocated since the last garbage collection.
6050 If this portion is smaller than `gc-cons-threshold', this is ignored. */);
6051 Vgc_cons_percentage = make_float (0.1);
6021 6052
6022 DEFVAR_INT ("pure-bytes-used", &pure_bytes_used, 6053 DEFVAR_INT ("pure-bytes-used", &pure_bytes_used,
6023 doc: /* Number of bytes of sharable Lisp data allocated so far. */); 6054 doc: /* Number of bytes of sharable Lisp data allocated so far. */);
6024 6055
6025 DEFVAR_INT ("cons-cells-consed", &cons_cells_consed, 6056 DEFVAR_INT ("cons-cells-consed", &cons_cells_consed,