Skip to content
Permalink
Browse files

sserver ETH: Fix memory leak during DAG switch.

  • Loading branch information
SwimmingTiger committed Feb 1, 2020
1 parent 81dce46 commit bb6cd95fc9967013f034e61c533d70f4db923e41
Showing with 25 additions and 1 deletion.
  1. +11 −0 src/Utils.h
  2. +3 −1 src/eth/StratumServerEth.cc
  3. +11 −0 tools/stratum_log_proxy/src/StratumBase.hpp
@@ -223,6 +223,17 @@ class SeqMap {
}
}
}

void clear(size_t maxSize, std::function<void(V)> delFun) {
while (queue_.size() > maxSize) {
auto itr = map_.find(queue_.front());
queue_.pop();
if (itr != map_.end()) {
if(delFun) delFun(itr->second);
map_.erase(itr);
}
}
}
};

class IdGenerator {
@@ -287,7 +287,9 @@ void EthashCalculator::buildDagCache(uint64_t height) {

// remove redundant caches
ScopeLock sl(lock_);
lightCaches_.clear(kMaxCacheSize_);
lightCaches_.clear(kMaxCacheSize_, [](ethash_light_t eth) {
if(eth) ethash_light_delete(eth);
});
}

void EthashCalculator::rebuildDagCache(uint64_t height) {
@@ -177,6 +177,17 @@ class SeqMap {
}
}

void clear(size_t maxSize, std::function<void(V)> delFun) {
while (queue_.size() > maxSize) {
auto itr = map_.find(queue_.front());
queue_.pop();
if (itr != map_.end()) {
if(delFun) delFun(itr->second);
map_.erase(itr);
}
}
}

bool pop(pair<K, V> &result) {
auto itr = map_.find(queue_.front());
queue_.pop();

0 comments on commit bb6cd95

Please sign in to comment.
You can’t perform that action at this time.