From 231083d46877d8bc3116154c6d505903466f68fd Mon Sep 17 00:00:00 2001 From: yangfei Date: Mon, 5 Nov 2018 18:48:21 +0800 Subject: [PATCH] repair bug of memory free --- src/framework/executor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/framework/executor.cpp b/src/framework/executor.cpp index 1b441bc5bd..81bfaf3a4d 100644 --- a/src/framework/executor.cpp +++ b/src/framework/executor.cpp @@ -649,12 +649,14 @@ void Executor::InitMemory() { template <> void Executor::InitCombineMemory() { - char *origin_data; + char *origin_data = nullptr; + bool self_alloc = false; if (program_.combined_params_buf && program_.combined_params_len) { LOG(kLOG_INFO) << "use outter memory"; origin_data = reinterpret_cast(program_.combined_params_buf); } else { LOG(kLOG_INFO) << " begin init combine memory"; + self_alloc = true; origin_data = ReadFileToBuff(program_.para_path); } PADDLE_MOBILE_ENFORCE(origin_data != nullptr, "origin_data==nullptr!!!"); @@ -701,7 +703,9 @@ void Executor::InitCombineMemory() { } } } - delete origin_data; + if (self_alloc) { + delete origin_data; + } LOG(kLOG_INFO) << " end init combine memory "; } -- GitLab