From fd1971caa0f90b3e279fa394f9a61edb1282da9d Mon Sep 17 00:00:00 2001 From: Yiqun Liu Date: Mon, 7 May 2018 09:53:30 +0800 Subject: [PATCH] Add the call of DropKids at the end of executor.Run to delete the local scopes created in operators (#10403) * Add the call of DeleteScope to delete the memory of scope created by NewScope. * Call DropKids at the end of executor.Run to delete all local scopes created in operators. --- paddle/fluid/framework/executor.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paddle/fluid/framework/executor.cc b/paddle/fluid/framework/executor.cc index 766bf0ab0..ce91d7a82 100644 --- a/paddle/fluid/framework/executor.cc +++ b/paddle/fluid/framework/executor.cc @@ -348,8 +348,12 @@ void Executor::RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope, } } } + platform::DeviceContextPool::Instance().Get(place_)->Wait(); if (create_vars && create_local_scope) { scope->DeleteScope(local_scope); + } else { + // Delete the local scopes created in operators. + scope->DropKids(); } if (FLAGS_benchmark) { VLOG(2) << "-------------------------------------------------------"; -- GitLab