aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorRichard M. Stallman2004-12-21 11:30:31 +0000
committerRichard M. Stallman2004-12-21 11:30:31 +0000
commit3c7e66a8a779703a4dccad2be562f0073e44f966 (patch)
tree856d50c890c677b74e1c7f261ee802bf3b5fbe09 /src/alloc.c
parente9a2654a9d026fede690ab753227f1210f8c2f4f (diff)
downloademacs-3c7e66a8a779703a4dccad2be562f0073e44f966.tar.gz
emacs-3c7e66a8a779703a4dccad2be562f0073e44f966.zip
(Fgarbage_collect): Update call to truncate_undo_list.
Call that at the very start. (undo_limit, undo_strong_limit, undo_outer_limit): To undo.c. (syms_of_alloc): Don't define undo-limit, undo-strong-limit and undo-outer-limit here.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c104
1 files changed, 37 insertions, 67 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 5038fdfce10..83de92520c4 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -200,12 +200,6 @@ extern
200#endif /* VIRT_ADDR_VARIES */ 200#endif /* VIRT_ADDR_VARIES */
201int malloc_sbrk_unused; 201int malloc_sbrk_unused;
202 202
203/* Two limits controlling how much undo information to keep. */
204
205EMACS_INT undo_limit;
206EMACS_INT undo_strong_limit;
207EMACS_INT undo_outer_limit;
208
209/* Number of live and free conses etc. */ 203/* Number of live and free conses etc. */
210 204
211static int total_conses, total_markers, total_symbols, total_vector_size; 205static int total_conses, total_markers, total_symbols, total_vector_size;
@@ -4644,13 +4638,48 @@ returns nil, because real GC can't be done. */)
4644 if (abort_on_gc) 4638 if (abort_on_gc)
4645 abort (); 4639 abort ();
4646 4640
4647 EMACS_GET_TIME (t1);
4648
4649 /* Can't GC if pure storage overflowed because we can't determine 4641 /* Can't GC if pure storage overflowed because we can't determine
4650 if something is a pure object or not. */ 4642 if something is a pure object or not. */
4651 if (pure_bytes_used_before_overflow) 4643 if (pure_bytes_used_before_overflow)
4652 return Qnil; 4644 return Qnil;
4653 4645
4646 /* Don't keep undo information around forever.
4647 Do this early on, so it is no problem if the user quits. */
4648 {
4649 register struct buffer *nextb = all_buffers;
4650
4651 while (nextb)
4652 {
4653 /* If a buffer's undo list is Qt, that means that undo is
4654 turned off in that buffer. Calling truncate_undo_list on
4655 Qt tends to return NULL, which effectively turns undo back on.
4656 So don't call truncate_undo_list if undo_list is Qt. */
4657 if (! EQ (nextb->undo_list, Qt))
4658 truncate_undo_list (nextb);
4659
4660 /* Shrink buffer gaps, but skip indirect and dead buffers. */
4661 if (nextb->base_buffer == 0 && !NILP (nextb->name))
4662 {
4663 /* If a buffer's gap size is more than 10% of the buffer
4664 size, or larger than 2000 bytes, then shrink it
4665 accordingly. Keep a minimum size of 20 bytes. */
4666 int size = min (2000, max (20, (nextb->text->z_byte / 10)));
4667
4668 if (nextb->text->gap_size > size)
4669 {
4670 struct buffer *save_current = current_buffer;
4671 current_buffer = nextb;
4672 make_gap (-(nextb->text->gap_size - size));
4673 current_buffer = save_current;
4674 }
4675 }
4676
4677 nextb = nextb->next;
4678 }
4679 }
4680
4681 EMACS_GET_TIME (t1);
4682
4654 /* In case user calls debug_print during GC, 4683 /* In case user calls debug_print during GC,
4655 don't let that cause a recursive GC. */ 4684 don't let that cause a recursive GC. */
4656 consing_since_gc = 0; 4685 consing_since_gc = 0;
@@ -4689,42 +4718,6 @@ returns nil, because real GC can't be done. */)
4689 4718
4690 shrink_regexp_cache (); 4719 shrink_regexp_cache ();
4691 4720
4692 /* Don't keep undo information around forever. */
4693 {
4694 register struct buffer *nextb = all_buffers;
4695
4696 while (nextb)
4697 {
4698 /* If a buffer's undo list is Qt, that means that undo is
4699 turned off in that buffer. Calling truncate_undo_list on
4700 Qt tends to return NULL, which effectively turns undo back on.
4701 So don't call truncate_undo_list if undo_list is Qt. */
4702 if (! EQ (nextb->undo_list, Qt))
4703 nextb->undo_list
4704 = truncate_undo_list (nextb->undo_list, undo_limit,
4705 undo_strong_limit, undo_outer_limit);
4706
4707 /* Shrink buffer gaps, but skip indirect and dead buffers. */
4708 if (nextb->base_buffer == 0 && !NILP (nextb->name))
4709 {
4710 /* If a buffer's gap size is more than 10% of the buffer
4711 size, or larger than 2000 bytes, then shrink it
4712 accordingly. Keep a minimum size of 20 bytes. */
4713 int size = min (2000, max (20, (nextb->text->z_byte / 10)));
4714
4715 if (nextb->text->gap_size > size)
4716 {
4717 struct buffer *save_current = current_buffer;
4718 current_buffer = nextb;
4719 make_gap (-(nextb->text->gap_size - size));
4720 current_buffer = save_current;
4721 }
4722 }
4723
4724 nextb = nextb->next;
4725 }
4726 }
4727
4728 gc_in_progress = 1; 4721 gc_in_progress = 1;
4729 4722
4730 /* clear_marks (); */ 4723 /* clear_marks (); */
@@ -5999,29 +5992,6 @@ prevent garbage collection during a part of the program. */);
5999 doc: /* Non-nil means loading Lisp code in order to dump an executable. 5992 doc: /* Non-nil means loading Lisp code in order to dump an executable.
6000This means that certain objects should be allocated in shared (pure) space. */); 5993This means that certain objects should be allocated in shared (pure) space. */);
6001 5994
6002 DEFVAR_INT ("undo-limit", &undo_limit,
6003 doc: /* Keep no more undo information once it exceeds this size.
6004This limit is applied when garbage collection happens.
6005The size is counted as the number of bytes occupied,
6006which includes both saved text and other data. */);
6007 undo_limit = 20000;
6008
6009 DEFVAR_INT ("undo-strong-limit", &undo_strong_limit,
6010 doc: /* Don't keep more than this much size of undo information.
6011A previous command which pushes the undo list past this size
6012is entirely forgotten when GC happens.
6013The size is counted as the number of bytes occupied,
6014which includes both saved text and other data. */);
6015 undo_strong_limit = 30000;
6016
6017 DEFVAR_INT ("undo-outer-limit", &undo_outer_limit,
6018 doc: /* Don't keep more than this much size of undo information.
6019If the current command has produced more than this much undo information,
6020GC discards it. This is a last-ditch limit to prevent memory overflow.
6021The size is counted as the number of bytes occupied,
6022which includes both saved text and other data. */);
6023 undo_outer_limit = 300000;
6024
6025 DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages, 5995 DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages,
6026 doc: /* Non-nil means display messages at start and end of garbage collection. */); 5996 doc: /* Non-nil means display messages at start and end of garbage collection. */);
6027 garbage_collection_messages = 0; 5997 garbage_collection_messages = 0;