I have a more general question about RAM use and refreshing stimuli/events/item. I hope I am posting in the right section.
Does refreshing stimuli or text properties per frame use considerably more RAM than refreshing the same text or stimuli per repeat (or setting them as a constant?).
The reason I am asking the question is that we are experiencing a persistent memory leak in one of our tasks. The task consists of two phases. Only in one phase does the RAM keep ramping up. The only noticeable difference between the two phases is the refresh rate.
I can confirm that re-setting TextStim properties (height, position etc.) on every frame in this version of PsychoPy (and perhaps other versions) seems to produce a memory leak, where the buffer will slowly but surely fill up until the task crashes.
There was a memory leak issue in pyglet which was specific to updating text content (not position), and as far as I know what supposed to have been addressed within pyglet a few years back, which was then incorporated in PsychoPy releases:
This should be perfectly fine coding practice (indeed, a lot of PsychoPy tasks rely on producing frame-by-frame animation, which requires exactly this sort of updating).
It would perhaps be useful for developers to see a minimal reproducible example that illustrates the problem.
I had a similar problem in PsychoPy2 v1.85.3. I was checking for keyboard responses every frame and creating a TextStim component (with the same name every time) to display a brief message every time a response was made. The program crashed after a while, reporting:
I tried updating the text property of an existing TextStim component each time there was a response, instead of creating a new TextStim component each time, but the problem was the same, as Michael stated above. I also tried changing the opacity of the TextStim component, but opacity could not be adjusted dynamically. And I tried a solution, suggested at https://discourse.psychopy.org/t/changing-the-opacity-of-text-mid-routine/8574, which involved overlaying the TextStim with a polygon and changing the opacity of the polygon, but the same crash occurred. Finally, I tried using a TextBox component instead of a TextStim component, but the TextBox component was not displayed at all (problems with TextBox components have also been reported here: : https://discourse.psychopy.org/t/using-textbox-instead-of-textstim/4818.
In the end, what worked was updating to PsychoPy3 v3.2.4!
I also seem to be having the same problem.
I tried to create a dynamic interface where the text stim updated every frame.
It is creating a memory leak in v2020 1.2.
This is in PsychoJS since I need to run this online.