How to Close Offscreen Windows

Hi all,


My apologies if this is a redundancy -- I'm attempting to solve two issues which may or may not be related. One has to do with PsychPort Audio, and the issue I'm looking for help with here has to do with offscreen windows or textures remaining open and taking up space. My script runs fine until around 40 trials or so into the experiment, when it crashes and gives an error related to PsychPort Audio. Another messages shows that a number of offscreen windows and textures remain open. Here is the full message I receive (the middle block is the part I'm focusing on here):


"PTB-INFO: New audio device with handle 1 opened as PortAudio stream:

PTB-INFO: For 1 channels Playback: Audio subsystem is ASIO, Audio device name is AudioBox ASIO Driver

PTB-INFO: Real samplerate 44100.000000 Hz. Input latency 9.795918 msecs, Output latency 21.814059 msecs.

PTB-ERROR: Failed to start audio device 1. PortAudio reports this error: Unanticipated host error 

INTERNAL PSYCHTOOLBOX ERROR

error:                PsychError_system

general description:  Error reported by a system call

specific description: Failed to start PortAudio audio device.

module name:          PsychPortAudio

subfunction call:     Start

file name:            Common\PsychPortAudio\PsychPortAudio.c

function name:        PSYCHPORTAUDIOStartAudioDevice

line number:          4201



PTB-INFO: There are still 232 textures, offscreen windows or proxy windows open. Screen('CloseAll') will auto-close them.

PTB-INFO: This may be fine for studies where you only use a few textures or windows, but a large number of open

PTB-INFO: textures or offscreen windows can be an indication that you forgot to dispose no longer needed items

PTB-INFO: via a proper call to Screen('Close', [windowOrTextureIndex]); , e.g., at the end of each trial. These

PTB-INFO: stale objects linger around and can consume significant memory ressources, causing degraded performance,

PTB-INFO: timing trouble (if the system has to resort to disk paging) and ultimately out of memory conditions or

PTB-INFO: crashes. Please check your code. (Screen('Close') is a quick way to release all textures and offscreen windows)




INFO: PTB's Screen('Flip', 10) command seems to have missed the requested stimulus presentation deadline

INFO: a total of 147 times out of a total of 516 flips during this session.


INFO: This number is fairly accurate (and indicative of real timing problems in your own code or your system)

INFO: if you provided requested stimulus onset times with the 'when' argument of Screen('Flip', window [, when]);

INFO: If you called Screen('Flip', window); without the 'when' argument, this count is more of a ''mild'' indicator

INFO: of timing behaviour than a hard reliable measurement. Large numbers may indicate problems and should at least

INFO: deserve your closer attention. Cfe. 'help SyncTrouble', the FAQ section at www.psychtoolbox.org and the

INFO: examples in the PDF presentation in PsychDocumentation/Psychtoolbox3-Slides.pdf for more info and timing tips.


Error using PsychPortAudio

See error message printed above.


Error in ProGrad4 (line 343)

        PsychPortAudio('Start',audiochannel,1);  % starts playing"


I tried to use the suggested command, "Screen('CloseAll')", to solve this issue, but that resulted in another error because it is also closing the on screen windows that I need. Any idea how I can close JUST the offscreen windows after each trial?


Thanks!

James Falandays, Villanova University


Not sure what the PsychAudioPort error is, but the first place to start would be to re-read the error message and follow the instructions. 

If you have a look it provides you with code showing you how to just close the open textures which are causing the issues rather then closing everything with Screen('CloseAll'). Give that a go and see if it works. 

The specifics of how you would do this in your script would depend on its logical structure. So if you wanted more advice in this regard you would have to provide some minimal code showing the error. However, it seems unlikely that you would need >200 textures open at one time. 

Its possible that this will fix things completely if the PsychPortAudio errors are trigger by the crash caused by the textures. 

Report back. 

Peter




the display textures are usually created using a function call of this form:

texture = Screen('MakeTexture', window, image_matrix, ...)

where 'window' is a PsychToolbox window handle and 'image_matrix' is a MATLAB matrix that contains the image to be rendered into a texture.

if you have textures accumulating, then most likely every trial loop is creating new textures and not releasing them.

to close the texture created above you can use something like:

Screen('Close', texture)

run the command:

Screen('Close?')

in a MATLAB command window for more information about that...