diff --git a/src/framework/executor.cpp b/src/framework/executor.cpp index 1b441bc5bdfed264f525dda571278067d2ae99b7..81bfaf3a4d07f5a3ef82c19de57f1681dfc1f8c7 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 "; }