From 1f262f9f61f86b906deccd1a0f9767e19a6e92b4 Mon Sep 17 00:00:00 2001 From: Jiaying Zhao Date: Thu, 26 Dec 2019 11:34:20 +0800 Subject: [PATCH] [Mobile][ARM]Fix memory leaks when using input tensor created with external pointer in lod_mode. (#2681) --- mobile/src/framework/executor.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mobile/src/framework/executor.cpp b/mobile/src/framework/executor.cpp index 169ab63307..d03cefe59a 100644 --- a/mobile/src/framework/executor.cpp +++ b/mobile/src/framework/executor.cpp @@ -363,7 +363,10 @@ void Executor::InitNoPersistableMemory(const Tensor &input_tensor) { DLOG << "InitNoPersistableMemory var " << var_desc->Name(); auto tensor = var->template GetMutable(); if (tensor->IsInitialized() && tensor->dims().size() == 4) { - DLOG << "var's tensor is Initialized or dims size != 4"; + // don't change user's input and avoid memory leaks + if (feed_indices_.find(var_desc->Name()) != feed_indices_.end()) { + break; + } DDim tensor_dim = tensor->dims(); DDim new_dim = make_ddim({tensor_dim[0], tensor_dim[1], input_tensor.dims()[2], -- GitLab