Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

Inline_script based GUI: "error: Out of memory"

I have been working on the same code for a while now which includes a GUI written in Python inline script. The GUI has worked for many iterations of the program in the past, but now crashes if the GUI is left active for to long. As far as I can tell, the Traceback doesn't indicate any of my code as being the problem (I could be mistaken). The error, which appears in multiple variations of the program, reads as follows:

File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\inline_script.py", line 102, in run
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\python_workspace.py", line 161, in _exec
exec(bytecode, self._globals)
File "", line 24, in
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\openexp\canvas.py", line 51, in canvas
return cls(experiment, *arglist, **kwdict)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\openexp_canvas\legacy.py", line 83, in __init__
self.surface = self.experiment.surface.copy()
error: Out of memory

Any assistance would be welcome!


  • sebastiaansebastiaan Posts: 2,989


    As of 3.1, there is an option to disable automatic garbage collection (the variable disable_garbage_collection). When garbage collection is disabled, OpenSesame manually frees unused memory at the end of each sequence (instead of at random intervals, which happens with automatic garbage collection). The reason for disabling automatic garbage collection is that it sometimes kicked in when it shouldn't, leading to timing glitches, and sometimes didn't kick in when it should, leading to memory errors.

    But if you have a very long inline_script, the lack of garbage collection may cause memory to run out.
    To work around this, you can re-enable automatic garbage collection

    import gc

    Or occasionally force a single garbage collection with:

    import gc

    See also:


    Thanked by 2kabaacke eduard

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.

  • DefneDefne Posts: 1

    Hi ,

    I am using OpenSesame 2.9.7 with Eyelink and got an ''Out of memory'' error.

    Following your advice above, I've
    - opened my experiment with opensesame 3.1.1 with Eyelink
    - added ''import gc gc.collect ()'' to my script.
    - saved my experiment under a different name with an .osexp extension

    This time, the experiment is giving me the RuntimeError: Link terminated.

    What next steps would you suggest in resolving this situation?


  • sebastiaansebastiaan Posts: 2,989

    Hi @Defne,

    The Link terminated error is (probably) unrelated to the memory error. Would you mind opening a new discussion for this, in which you describe the issue in more detail, including the complete stack trace (which you can find in the debug window) and when the crash occurs. It would also be helpful if you attach the actual experiment script to the discussion.


    There's much bigger issues in the world, I know. But I first have to take care of the world I know.

Sign In or Register to comment.