Commit e39d9e96 authored by Adam P. Goucher's avatar Adam P. Goucher

Staged garbage collection in streamlife

parent 4d3eefca
......@@ -53,10 +53,14 @@ namespace apg {
if (threshold) {
uint64_t oldsize = this->htree.total_bytes() + biresults.total_bytes();
if (oldsize >= threshold) {
std::cerr << "Garbage-collecting streamlife (" << oldsize << " >= " << threshold << ")" << std::endl;
this->htree.gc_full();
std::cerr << "Emptying streamlife biresults (" << oldsize << " >= " << threshold << ")" << std::endl;
biresults.clear();
uint64_t newsize = this->htree.total_bytes() + biresults.total_bytes();
if (newsize >= ((threshold * 3) / 4)) {
std::cerr << "Insufficient memory liberated; entering full garbage collection..." << std::endl;
this->htree.gc_full();
newsize = this->htree.total_bytes() + biresults.total_bytes();
}
std::cerr << "Streamlife size reduced from " << oldsize << " to " << newsize << " bytes." << std::endl;
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment