takeOwnershipOfPipes method releases memory
authorYuri Putivsky <yuri@fb.com>
Fri, 29 Jul 2016 02:19:25 +0000 (19:19 -0700)
committerFacebook Github Bot 0 <facebook-github-bot-0-bot@fb.com>
Fri, 29 Jul 2016 02:23:48 +0000 (19:23 -0700)
Summary: takeOwnershipOfPipes should left zero heap memory allocated in folly:Subprocess class instance.

Reviewed By: snarkmaster

Differential Revision: D3638503

fbshipit-source-id: aac7b10bd7399c44868f32c01164f4123892598f

folly/Subprocess.cpp

index 1e294ba767b985b91d083877f9eab3984cfe324d..d7d28d9f4b150dd58375023bbf78ef85f4341105 100644 (file)
@@ -832,7 +832,8 @@ std::vector<Subprocess::ChildPipe> Subprocess::takeOwnershipOfPipes() {
   for (auto& p : pipes_) {
     pipes.emplace_back(p.childFd, std::move(p.pipe));
   }
-  pipes_.clear();
+  // release memory
+  std::vector<Pipe>().swap(pipes_);
   return pipes;
 }