From 7ef830bef13aaf32a78037dac4a5e6b7bfc390b7 Mon Sep 17 00:00:00 2001 From: Eric Liang Date: Sun, 3 Feb 2019 18:34:37 -0800 Subject: [PATCH] [rllib] Add copy() in async samples optimizer to fix memory leak (#3938) Fixes #3884. --- python/ray/rllib/optimizers/async_samples_optimizer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/ray/rllib/optimizers/async_samples_optimizer.py b/python/ray/rllib/optimizers/async_samples_optimizer.py index 60b4eb69176c3..541bcc1fa1c10 100644 --- a/python/ray/rllib/optimizers/async_samples_optimizer.py +++ b/python/ray/rllib/optimizers/async_samples_optimizer.py @@ -167,7 +167,8 @@ def _step(self): for b in self.batch_buffer) >= self.train_batch_size: train_batch = self.batch_buffer[0].concat_samples( self.batch_buffer) - self.learner.inqueue.put(train_batch) + # defensive copy against plasma ref count bugs, see #3884 + self.learner.inqueue.put(train_batch.copy()) self.batch_buffer = [] # If the batch was replayed, skip the update below.