+2009-09-10 Ivan Maidanski <ivmai@mail.ru>
+ (diff118_cvs - superseding diff53)
+
+ * allchblk.c (MUNMAP_THRESHOLD): Move macro definition out of
+ a function.
+ * allchblk.c (GC_unmap_threshold): New global variable definition
+ (initialized to MUNMAP_THRESHOLD).
+ * allchblk.c (GC_unmap_old): Use GC_unmap_threshold instead of
+ MUNMAP_THRESHOLD; skip unmapping if GC_unmap_threshold is 0.
+ * doc/README.environment (GC_UNMAP_THRESHOLD): Add information.
+ * misc.c (GC_unmap_threshold): New variable declaration.
+ * misc.c (GC_init_inner): Recognize "GC_UNMAP_THRESHOLD"
+ environment variable to set GC_unmap_threshold value (only if
+ USE_MUNMAP).
+
2009-09-10 Ivan Maidanski <ivmai@mail.ru>
(diff117)
GC_check_finalizer_nested): Ditto.
2009-09-10 Ivan Maidanski <ivmai@mail.ru>
- (diff103_cvs)
+ (diff103_cvs - resembling diff78, diff88_cvs, diff99_cvs,
+ diff100_cvs, diff101_cvs, diff102_cvs)
* alloc.c (GC_stopped_mark): Remove GC_log_printf("") (not needed
anymore and GCC produces a warning for it).
#ifdef USE_MUNMAP
+# ifndef MUNMAP_THRESHOLD
+# define MUNMAP_THRESHOLD 6
+# endif
+
+int GC_unmap_threshold = MUNMAP_THRESHOLD;
+
/* Unmap blocks that haven't been recently touched. This is the only way */
/* way blocks are ever unmapped. */
void GC_unmap_old(void)
{
struct hblk * h;
hdr * hhdr;
- word sz;
- unsigned short last_rec, threshold;
int i;
-# ifndef MUNMAP_THRESHOLD
-# define MUNMAP_THRESHOLD 6
-# endif
+
+ if (GC_unmap_threshold == 0)
+ return; /* unmapping disabled */
for (i = 0; i <= N_HBLK_FLS; ++i) {
for (h = GC_hblkfreelist[i]; 0 != h; h = hhdr -> hb_next) {
hhdr = HDR(h);
if (!IS_MAPPED(hhdr)) continue;
- threshold = (unsigned short)(GC_gc_no - MUNMAP_THRESHOLD);
- last_rec = hhdr -> hb_last_reclaimed;
- if ((last_rec > GC_gc_no || last_rec < threshold)
- && threshold < GC_gc_no /* not recently wrapped */) {
- sz = hhdr -> hb_sz;
- GC_unmap((ptr_t)h, sz);
+
+ if ((unsigned short)GC_gc_no - hhdr -> hb_last_reclaimed >
+ (unsigned short)GC_unmap_threshold) {
+ GC_unmap((ptr_t)h, hhdr -> hb_sz);
hhdr -> hb_flags |= WAS_UNMAPPED;
}
}
Setting it to larger values decreases space consumption
and increases GC frequency.
+GC_UNMAP_THRESHOLD - Set the desired memory blocks unmapping threshold (the
+ number of sequential garbage collections for which
+ a candidate block for unmapping should remain free). The
+ special value "0" completely disables unmapping.
+
GC_FIND_LEAK - Turns on GC_find_leak and thus leak detection. Forces a
collection at program termination to detect leaks that would
otherwise occur after the last GC.
void GC_thr_init(void);
#endif
+#ifdef USE_MUNMAP
+ extern int GC_unmap_threshold;
+#endif
+
void GC_init_inner(void)
{
# if !defined(THREADS) && defined(GC_ASSERTIONS)
GC_free_space_divisor = (GC_word)space_divisor;
}
}
+# ifdef USE_MUNMAP
+ {
+ char * string = GETENV("GC_UNMAP_THRESHOLD");
+ if (string != NULL) {
+ if (*string == '0' && *(string + 1) == '\0') {
+ /* "0" is used to disable unmapping. */
+ GC_unmap_threshold = 0;
+ } else {
+ int unmap_threshold = atoi(string);
+ if (unmap_threshold > 0)
+ GC_unmap_threshold = unmap_threshold;
+ }
+ }
+ }
+# endif
maybe_install_looping_handler();
/* Adjust normal object descriptor for extra allocation. */
if (ALIGNMENT > GC_DS_TAGS && EXTRA_BYTES != 0) {