summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-27 10:25:54 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-27 10:25:54 -0700
commitba911c661c4a3607c80dcd0c30d4313e558a9243 (patch)
tree18dea7bbd3ea0813320997e901ab40511b540438
parente5145afe93cd5290878ac432aea87da9c70d1263 (diff)
downloadtxr-ba911c661c4a3607c80dcd0c30d4313e558a9243.tar.gz
txr-ba911c661c4a3607c80dcd0c30d4313e558a9243.tar.bz2
txr-ba911c661c4a3607c80dcd0c30d4313e558a9243.zip
Full gc should be done if driven by malloc.
* gc.c (gc): If the number of bytes malloced since the last gc exceeds the gc delta, we must do do a full garbage collection. The mature generation is almost certainly holding on to a lot of that memory. A test case for this is (lazy-str-force (lazy-str (get-lines (open-file "file")))). The file doesn't even have to be very large.
-rw-r--r--gc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index af91bba7..9128e9d9 100644
--- a/gc.c
+++ b/gc.c
@@ -674,6 +674,11 @@ void gc(void)
assert (gc_enabled);
+#if CONFIG_GEN_GC
+ if (malloc_bytes - prev_malloc_bytes >= opt_gc_delta)
+ full_gc = 1;
+#endif
+
save_context(mc);
gc_enabled = 0;
mark(&mc, &gc_stack_top);