about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-09-17T13·19+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-09-17T13·19+0200
commit6e5b02bee4c117863f11e4697da9e4f55b81e52d (patch)
tree098e21f7dc48ff3da8d2ce2b918a8df6fd0a9b73 /src/libexpr/eval.cc
parentd37d0127742a7574d4f48860de2e82fb523e508a (diff)
Add some instrumentation for debugging GC leaks
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 2af6a6787d..70b3365639 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -230,6 +230,8 @@ EvalState::EvalState(const Strings & _searchPath)
 
 EvalState::~EvalState()
 {
+    fileEvalCache.clear();
+    printCanaries();
 }
 
 
@@ -1464,4 +1466,24 @@ void EvalState::printStats()
 }
 
 
+void EvalState::printCanaries()
+{
+#if HAVE_BOEHMGC
+    if (!settings.get("debug-gc", false)) return;
+
+    GC_gcollect();
+
+    if (gcCanaries.empty()) {
+        printMsg(lvlError, "all canaries have been garbage-collected");
+        return;
+    }
+
+    printMsg(lvlError, "the following canaries have not been garbage-collected:");
+
+    for (auto i : gcCanaries)
+        printMsg(lvlError, format("  %1%") % i->string.s);
+#endif
+}
+
+
 }