diff options
-rw-r--r-- | eval.cpp | 3 | ||||
-rw-r--r-- | gc.cpp | 7 | ||||
-rw-r--r-- | gc.h | 1 | ||||
-rw-r--r-- | main.cpp | 6 |
4 files changed, 11 insertions, 6 deletions
@@ -207,8 +207,7 @@ EvalObj *Evaluator::run_expr(Pair *prog) { call(args, envt, cont, top_ptr); else throw TokenError(opt->ext_repr(), SYN_ERR_CAN_NOT_APPLY); - gc.force(); - gc.cycle_resolve(); + gc.collect(); } } } @@ -151,6 +151,13 @@ void GarbageCollector::cycle_resolve() { #ifdef GC_INFO fprintf(stderr, "GC: cycle resolved.\n"); #endif +} + +void GarbageCollector::collect() { + force(); + if (mapping.size() < resolve_threshold) + return; + cycle_resolve(); force(); } @@ -37,6 +37,7 @@ class GarbageCollector { public: GarbageCollector(); + void collect(); void cycle_resolve(); void force(); void expose(EvalObj *ptr); @@ -35,8 +35,7 @@ void load_file(const char *fname) { { fprintf(stderr, "An error occured: %s\n", e.get_msg().c_str()); } - gc.force(); - gc.cycle_resolve(); + gc.collect(); } } @@ -109,7 +108,6 @@ int main(int argc, char **argv) { { fprintf(stderr, "An error occured: %s\n", e.get_msg().c_str()); } - gc.force(); - gc.cycle_resolve(); + gc.collect(); } } |