diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-05-21T13·21+0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-05-21T13·21+0200 |
commit | 13493ef97c01a9839c340cbe4e99baae65b20e15 (patch) | |
tree | f1c769d4b2fc967265cf6ac0488dfdcd165ba502 /src/libmain | |
parent | 4441e4cc13ded59e1a57c3d47e7920dd6a3053fa (diff) |
nix-collect-garbage: Call collectGarbage() internally
Diffstat (limited to 'src/libmain')
-rw-r--r-- | src/libmain/shared.cc | 15 | ||||
-rw-r--r-- | src/libmain/shared.hh | 17 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index c83e997b2307..f300fbf1b463 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -342,4 +342,19 @@ RunPager::~RunPager() } +string showBytes(unsigned long long bytes) +{ + return (format("%.2f MiB") % (bytes / (1024.0 * 1024.0))).str(); +} + + +PrintFreed::~PrintFreed() +{ + if (show) + std::cout << format("%1% store paths deleted, %2% freed\n") + % results.paths.size() + % showBytes(results.bytesFreed); +} + + } diff --git a/src/libmain/shared.hh b/src/libmain/shared.hh index b662c6ccea96..a7e6ef762120 100644 --- a/src/libmain/shared.hh +++ b/src/libmain/shared.hh @@ -83,4 +83,21 @@ private: extern volatile ::sig_atomic_t blockInt; + +/* GC helpers. */ + +string showBytes(unsigned long long bytes); + +class GCResults; + +struct PrintFreed +{ + bool show; + const GCResults & results; + PrintFreed(bool show, const GCResults & results) + : show(show), results(results) { } + ~PrintFreed(); +}; + + } |