提交 6a6ace05 编写于 作者: Y yangfei

repair bug of memory free

上级 a1766fa7
...@@ -649,12 +649,14 @@ void Executor<GPU_CL, Precision::FP32>::InitMemory() { ...@@ -649,12 +649,14 @@ void Executor<GPU_CL, Precision::FP32>::InitMemory() {
template <> template <>
void Executor<GPU_CL, Precision::FP32>::InitCombineMemory() { void Executor<GPU_CL, Precision::FP32>::InitCombineMemory() {
char *origin_data; char *origin_data = nullptr;
bool self_alloc = false;
if (program_.combined_params_buf && program_.combined_params_len) { if (program_.combined_params_buf && program_.combined_params_len) {
LOG(kLOG_INFO) << "use outter memory"; LOG(kLOG_INFO) << "use outter memory";
origin_data = reinterpret_cast<char *>(program_.combined_params_buf); origin_data = reinterpret_cast<char *>(program_.combined_params_buf);
} else { } else {
LOG(kLOG_INFO) << " begin init combine memory"; LOG(kLOG_INFO) << " begin init combine memory";
self_alloc = true;
origin_data = ReadFileToBuff(program_.para_path); origin_data = ReadFileToBuff(program_.para_path);
} }
PADDLE_MOBILE_ENFORCE(origin_data != nullptr, "origin_data==nullptr!!!"); PADDLE_MOBILE_ENFORCE(origin_data != nullptr, "origin_data==nullptr!!!");
...@@ -701,7 +703,9 @@ void Executor<GPU_CL, Precision::FP32>::InitCombineMemory() { ...@@ -701,7 +703,9 @@ void Executor<GPU_CL, Precision::FP32>::InitCombineMemory() {
} }
} }
} }
delete origin_data; if (self_alloc) {
delete origin_data;
}
LOG(kLOG_INFO) << " end init combine memory "; LOG(kLOG_INFO) << " end init combine memory ";
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册