提交 983fafa5 编写于 作者: I Igor Canadi

Fix memory leak

上级 04afa321
......@@ -31,6 +31,7 @@ MemTableListVersion::MemTableListVersion(MemTableListVersion* old) {
void MemTableListVersion::Ref() { ++refs_; }
void MemTableListVersion::Unref(std::vector<MemTable*>* to_delete) {
assert(refs_ >= 1);
--refs_;
if (refs_ == 0) {
// if to_delete is equal to nullptr it means we're confident
......@@ -255,6 +256,7 @@ void MemTableList::InstallNewVersion() {
// somebody else holds the current version, we need to create new one
MemTableListVersion* version = current_;
current_ = new MemTableListVersion(current_);
current_->Ref();
version->Unref();
}
}
......
......@@ -49,7 +49,7 @@ class MemTableListVersion {
friend class MemTableList;
std::list<MemTable*> memlist_;
int size_ = 0;
int refs_ = 1;
int refs_ = 0;
};
// This class stores references to all the immutable memtables.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册