From fc025f5265d40d7b9e427f8d0aa70d1e2e857a7b Mon Sep 17 00:00:00 2001 From: gongweibao Date: Tue, 24 Apr 2018 21:59:42 +0800 Subject: [PATCH] Fix memory leak of pserver (#10173) --- paddle/fluid/operators/detail/sendrecvop_utils.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/operators/detail/sendrecvop_utils.cc b/paddle/fluid/operators/detail/sendrecvop_utils.cc index 69fcffe9bc3..766bcf1ac5e 100644 --- a/paddle/fluid/operators/detail/sendrecvop_utils.cc +++ b/paddle/fluid/operators/detail/sendrecvop_utils.cc @@ -39,7 +39,9 @@ void SerializeToByteBuffer(const std::string& name, framework::Variable* var, // parallelism execution, need to know when to free the tensor. DestroyCallback destroy_callback = [](void* backing) {}; - void* buf = malloc(1024); + auto buffer = std::unique_ptr(new char[1024]); + void* buf = buffer.get(); + void* payload = nullptr; size_t payload_size; ProtoEncodeHelper e(static_cast(buf), 1024); -- GitLab