comparison src/mc-alloc.c @ 3305:1043bbfa24cf

[xemacs-hg @ 2006-03-26 15:24:25 by crestani] 2006-03-26 Marcus Crestani <crestani@xemacs.org> * alloc.c (malloc_warning): Move function into scope of MALLOC_END, add MALLOC_END. * alloc.c (memory_full): Add memory shortage indication, adjust error messages. * mc-alloc.c: Add memory_shortage. * mc-alloc.c (expand_heap): If memory is short, allocate only the needed pages, not more. * mc-alloc.h: Add memory_shortage.
author crestani
date Sun, 26 Mar 2006 15:24:27 +0000
parents 619edf713d55
children 229bd619740a
comparison
equal deleted inserted replaced
3304:73051095a712 3305:1043bbfa24cf
409 409
410 /************************************************************************/ 410 /************************************************************************/
411 /* MC Allocator */ 411 /* MC Allocator */
412 /************************************************************************/ 412 /************************************************************************/
413 413
414 /* Set to 1 if memory becomes short. */
415 EMACS_INT memory_shortage;
414 416
415 /*--- misc functions ---------------------------------------------------*/ 417 /*--- misc functions ---------------------------------------------------*/
416 418
417 /* moved here from alloc.c */ 419 /* moved here from alloc.c */
418 #ifdef ERROR_CHECK_GC 420 #ifdef ERROR_CHECK_GC
1134 EMACS_INT n_pages; 1136 EMACS_INT n_pages;
1135 size_t real_size; 1137 size_t real_size;
1136 void *real_start; 1138 void *real_start;
1137 1139
1138 /* determine number of pages the heap should grow */ 1140 /* determine number of pages the heap should grow */
1139 n_pages = needed_pages + (HEAP_SIZE / (PAGE_SIZE * HEAP_GROWTH_DIVISOR)); 1141 if (memory_shortage)
1140 if (n_pages < MIN_HEAP_INCREASE) 1142 n_pages = needed_pages;
1141 n_pages = MIN_HEAP_INCREASE; 1143 else
1144 n_pages = max (MIN_HEAP_INCREASE,
1145 needed_pages
1146 + (HEAP_SIZE / (PAGE_SIZE * HEAP_GROWTH_DIVISOR)));
1142 1147
1143 /* get the real values */ 1148 /* get the real values */
1144 real_size = (n_pages * PAGE_SIZE) + PAGE_SIZE; 1149 real_size = (n_pages * PAGE_SIZE) + PAGE_SIZE;
1145 real_start = xmalloc_and_zero (real_size); 1150 real_start = xmalloc_and_zero (real_size);
1146 #ifdef MEMORY_USAGE_STATS 1151 #ifdef MEMORY_USAGE_STATS