提交 2dd9e51e 编写于 作者: T Tensor Tang

Merge branch 'develop' into 'develop'

fix memory leak for tensor buffer and context

See merge request paddlepaddle/paddlelitearmbackend!8
......@@ -65,6 +65,8 @@ class Buffer {
TargetCopy(target_, data_, other.data_, nbytes);
}
~Buffer() { Free(); }
private:
// memory it actually malloced.
size_t space_{0};
......
......@@ -34,7 +34,6 @@ class Any {
CHECK(type_ == typeid(T).hash_code());
} else {
type_ = typeid(T).hash_code();
data_ = new T;
deleter_ = [&] { delete static_cast<T*>(data_); };
}
data_ = new T;
......@@ -55,10 +54,16 @@ class Any {
bool valid() const { return data_; }
~Any() {
if (valid()) {
deleter_();
}
}
private:
static size_t kInvalidType;
size_t type_{kInvalidType};
void* data_{};
void* data_{nullptr};
std::function<void()> deleter_;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册