# Rating scale memory leak?

**URL:** <https://discourse.psychopy.org/t/rating-scale-memory-leak/6891>\
**Category:** Coding\
**Created:** [March 3, 2019, 3:40am UTC](https://discourse.psychopy.org/t/rating-scale-memory-leak/6891 "2019-03-03T03:40:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel\_Ong](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/gabriel_ong/32/4036_2.png) [@Gabriel\_Ong](https://discourse.psychopy.org/u/Gabriel_Ong)\
**Post date:** [March 3, 2019, 3:40am UTC](https://discourse.psychopy.org/t/rating-scale-memory-leak/6891/1 "2019-03-03T03:40:58Z")

</div>

Hi there!

I’m currently programming an experiment in PsychoPy 3.0.5 with Python 2 where I present participants with 10 movies followed by 28 rating scale questions after each one.

The problem is, I’m running into the same rating scale memory leak issue as described here  
[https://groups.google.com/forum/m/#!msg/psychopy-users/1kA3oZq\_3Rg/RZisAyR9CAAJ](https://groups.google.com/forum/m/#!msg/psychopy-users/1kA3oZq_3Rg/RZisAyR9CAAJ)

Basically, presenting multiple rating scales throughout the experiment seems to slowly be eating up my RAM until psychopy decides to crash right around the last movie.

I’ve tried editing the rating scale code as described in the link above but it still crashes.

Has anyone been able to fix this issue? My last resort is to split the experiment into two.

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [March 3, 2019, 6:32am UTC](https://discourse.psychopy.org/t/rating-scale-memory-leak/6891/2 "2019-03-03T06:32:59Z")

</div>

It looks like @jeremygray fixed (most of) that issue with the commit here to his fork of PsychoPy:

> <https://github.com/jeremygray/psychopy/commit/a6411f62e5ae0d739eb0929f2425e32e7c0f2e70>
>
> \- likely due to leak in TextStim, where setText does not release mem for old tex…t
> \- partial solution = avoid doing setText every frame, use only when needed

But:

1. This is just a partial fix for an underlying problem in the `pyglet` drawing library, which is outside of PsychoPy. It should greatly reduce the rate of the memory leak, but not entirely eliminate it.
2. It doesn’t look like this fix was ever sent as a pull request to the main PsychoPy repository, so the fix has not yet been applied centrally.
3. You’ve made the fix yourself locally but it hasn’t changed things (which is surprising, I would have thought it would have given you a _much_ longer period of useful time before the leak became problematic).

So perhaps for you, the best option would be to switch from using the complex but comprehensive Rating Scale to the newer but simpler Slider class:

[https://www.psychopy.org/api/visual/slider.html](https://www.psychopy.org/api/visual/slider.html)

Please let us know if this resolves the issue for you?

---

<div class="post-metadata">

**Author:** ![Gabriel\_Ong](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/gabriel_ong/32/4036_2.png) [@Gabriel\_Ong](https://discourse.psychopy.org/u/Gabriel_Ong)\
**Post date:** [March 6, 2019, 4:38am UTC](https://discourse.psychopy.org/t/rating-scale-memory-leak/6891/3 "2019-03-06T04:38:32Z")

</div>

Hi @Michael

Thanks for your response. The fix Jeremy posted actually did help as the experiment lasted a bit longer, but it did still eventually crash (remember that I’m loading movies as well, which eats up memory).

Slider definitely works a lot better!
