# Memory issue debugging

**URL:** <https://discuss.ray.io/t/memory-issue-debugging/7573>\
**Category:** RLlib\
**Created:** [September 15, 2022, 8:22am UTC](https://discuss.ray.io/t/memory-issue-debugging/7573 "2022-09-15T08:22:51Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![mannyv](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mannyv/32/606_2.png) [@mannyv](https://discuss.ray.io/u/mannyv)\
**Post date:** [September 21, 2022, 9:00pm UTC](https://discuss.ray.io/t/memory-issue-debugging/7573/4 "2022-09-21T21:00:05Z")

</div>

Hi @Blubberblub,

My guess is that your environment is generating samples much faster than the training is consuming them. This is causing the sample queue to fill up in the policy server which is causing the memory issue.

Try adding the following print and see if this is growing:

> <https://github.com/ray-project/ray/blob/7ca334f4138b310353ceb473b03662d7de81f183/rllib/env/policy_server_input.py#L174-L176>

```python
    @override(InputReader)
    def next(self):
        print(f"Size of samples queue is: {self.samples_queue.qsize()}", )
        return self.samples_queue.get()

```

My env is not much faster than the training but if I artificially slow training down by putting a break point in the training call of the policy and waiting 20 seconds I see something like this:

```auto
Size of samples queue is: 6
Size of samples queue is: 5
Size of samples queue is: 5
Size of samples queue is: 5
Size of samples queue is: 4
Size of samples queue is: 3
Size of samples queue is: 4
Size of samples queue is: 3
Size of samples queue is: 2
Size of samples queue is: 1
Size of samples queue is: 1
Size of samples queue is: 0
Size of samples queue is: 0
Size of samples queue is: 0
Size of samples queue is: 0

```

---

_[View the full topic](https://discuss.ray.io/t/memory-issue-debugging/7573)._
