/[emacs]/emacs/src/alloc.c
ViewVC logotype

Diff of /emacs/src/alloc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.356 by jhd, Wed Dec 15 21:40:39 2004 UTC revision 1.357 by rms, Tue Dec 21 11:30:31 2004 UTC
# Line 200  extern Line 200  extern
200  #endif /* VIRT_ADDR_VARIES */  #endif /* VIRT_ADDR_VARIES */
201  int malloc_sbrk_unused;  int malloc_sbrk_unused;
202    
 /* Two limits controlling how much undo information to keep.  */  
   
 EMACS_INT undo_limit;  
 EMACS_INT undo_strong_limit;  
 EMACS_INT undo_outer_limit;  
   
203  /* Number of live and free conses etc.  */  /* Number of live and free conses etc.  */
204    
205  static int total_conses, total_markers, total_symbols, total_vector_size;  static int total_conses, total_markers, total_symbols, total_vector_size;
# Line 4644  returns nil, because real GC can't be do Line 4638  returns nil, because real GC can't be do
4638    if (abort_on_gc)    if (abort_on_gc)
4639      abort ();      abort ();
4640    
   EMACS_GET_TIME (t1);  
   
4641    /* Can't GC if pure storage overflowed because we can't determine    /* Can't GC if pure storage overflowed because we can't determine
4642       if something is a pure object or not.  */       if something is a pure object or not.  */
4643    if (pure_bytes_used_before_overflow)    if (pure_bytes_used_before_overflow)
4644      return Qnil;      return Qnil;
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    
4683    /* In case user calls debug_print during GC,    /* In case user calls debug_print during GC,
4684       don't let that cause a recursive GC.  */       don't let that cause a recursive GC.  */
4685    consing_since_gc = 0;    consing_since_gc = 0;
# Line 4689  returns nil, because real GC can't be do Line 4718  returns nil, because real GC can't be do
4718    
4719    shrink_regexp_cache ();    shrink_regexp_cache ();
4720    
   /* Don't keep undo information around forever.  */  
   {  
     register struct buffer *nextb = all_buffers;  
   
     while (nextb)  
       {  
         /* If a buffer's undo list is Qt, that means that undo is  
            turned off in that buffer.  Calling truncate_undo_list on  
            Qt tends to return NULL, which effectively turns undo back on.  
            So don't call truncate_undo_list if undo_list is Qt.  */  
         if (! EQ (nextb->undo_list, Qt))  
           nextb->undo_list  
             = truncate_undo_list (nextb->undo_list, undo_limit,  
                                   undo_strong_limit, undo_outer_limit);  
   
         /* Shrink buffer gaps, but skip indirect and dead buffers.  */  
         if (nextb->base_buffer == 0 && !NILP (nextb->name))  
           {  
             /* If a buffer's gap size is more than 10% of the buffer  
                size, or larger than 2000 bytes, then shrink it  
                accordingly.  Keep a minimum size of 20 bytes.  */  
             int size = min (2000, max (20, (nextb->text->z_byte / 10)));  
   
             if (nextb->text->gap_size > size)  
               {  
                 struct buffer *save_current = current_buffer;  
                 current_buffer = nextb;  
                 make_gap (-(nextb->text->gap_size - size));  
                 current_buffer = save_current;  
               }  
           }  
   
         nextb = nextb->next;  
       }  
   }  
   
4721    gc_in_progress = 1;    gc_in_progress = 1;
4722    
4723    /* clear_marks (); */    /* clear_marks (); */
# Line 5999  prevent garbage collection during a part Line 5992  prevent garbage collection during a part
5992                 doc: /* Non-nil means loading Lisp code in order to dump an executable.                 doc: /* Non-nil means loading Lisp code in order to dump an executable.
5993  This means that certain objects should be allocated in shared (pure) space.  */);  This means that certain objects should be allocated in shared (pure) space.  */);
5994    
   DEFVAR_INT ("undo-limit", &undo_limit,  
               doc: /* Keep no more undo information once it exceeds this size.  
 This limit is applied when garbage collection happens.  
 The size is counted as the number of bytes occupied,  
 which includes both saved text and other data.  */);  
   undo_limit = 20000;  
   
   DEFVAR_INT ("undo-strong-limit", &undo_strong_limit,  
               doc: /* Don't keep more than this much size of undo information.  
 A previous command which pushes the undo list past this size  
 is entirely forgotten when GC happens.  
 The size is counted as the number of bytes occupied,  
 which includes both saved text and other data.  */);  
   undo_strong_limit = 30000;  
   
   DEFVAR_INT ("undo-outer-limit", &undo_outer_limit,  
               doc: /* Don't keep more than this much size of undo information.  
 If the current command has produced more than this much undo information,  
 GC discards it.  This is a last-ditch limit to prevent memory overflow.  
 The size is counted as the number of bytes occupied,  
 which includes both saved text and other data.  */);  
   undo_outer_limit = 300000;  
   
5995    DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages,    DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages,
5996                 doc: /* Non-nil means display messages at start and end of garbage collection.  */);                 doc: /* Non-nil means display messages at start and end of garbage collection.  */);
5997    garbage_collection_messages = 0;    garbage_collection_messages = 0;

Legend:
Removed from v.1.356  
changed lines
  Added in v.1.357

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26