accumulating memory using OffScreenWindow

Matlab Gurus-

My question concerns how to close and clear memory allocated to
OffScreen windows.

I am writing an experiment (on a PC) in which I want to indefinitely
present an array of images every several hundred milliseconds, much
like an RSVP paradigm. I can successfully write my images to
OffScreenWindows and Copy these to the screen just fine. The gist of
the code is something like:

for pp = 1:number_of_presentations
draw stimuli to offscreenwindow
copy offscreen contents to onscreen
present stimuli for XXXms
close offscreenwindow
end

However, as the number of presentations (pp) increases, it seems that
there is a problem in clearing the memory from the previous
presentations. My intention is to close (and clear?) the contents of
the OffScreenWindow once it has been presented. Despite my efforts
to close (and clear) this window, I suspect that new memory is being
allocated every time I want to draw on an OffScreenWindow. My
suspicion is prompted by two factors: First, after many trials,
Matlab is very slow at returning to the Command Window. Second, I
put a counter in the while loop, responsible for maintaining each
stimuli on the screen for a set amount of time. The number of
iterations in this while loop decreases exponentially as the
experiment progresses.

How can I be sure that the memory for the OffScreenWindow is being
cleared? Is there a difference between closing a window and clearing
the memory used to draw the window? Are these even the right
questions to be asking? (I can fake my way through Matlab, but I
have no other programming experience.)

Thanks,
Jason

PS - This experiment is being incorporated with an Eyelink 2.
--
dear jason

memory is allocated for the offscreen window when you open the
offscreen window. the memory is freed when you close it. you wrote some
pseudocode in your query. it is much better practice to provide a
minimal program (a real program that can be run) that exhibits your
problem. if you had done so you would probably have discovered the
answer yourself.

opening and closing windows in most operating systems (including
Windows and Mac OS) is very slow, on the order of 1 second. so the
usual practice is to open windows once, at the beginning of the
experiment, and to keep them open during the whole experiment, and
close them all at the end, when we're done.

if you are showing a n-frame movie then you'll want n offscreen windows.

the pseudo code you provided won't work because you never open the
windows, you only close them.

the demo program movie.m, in the psychtoolbox, shows how to do this all
correctly.

good luck

denis pelli



s from memo
On Jan 25, 2005, at 5:57 PM, Jason Droll wrote:

>
>
> Matlab Gurus-
>
> My question concerns how to close and clear memory allocated to
> OffScreen windows.
>
> I am writing an experiment (on a PC) in which I want to indefinitely
> present an array of images every several hundred milliseconds, much
> like an RSVP paradigm. I can successfully write my images to
> OffScreenWindows and Copy these to the screen just fine. The gist of
> the code is something like:
>
> for pp = 1:number_of_presentations
> draw stimuli to offscreenwindow
> copy offscreen contents to onscreen
> present stimuli for XXXms
> close offscreenwindow
> end
>
> However, as the number of presentations (pp) increases, it seems that
> there is a problem in clearing the memory from the previous
> presentations. My intention is to close (and clear?) the contents of
> the OffScreenWindow once it has been presented. Despite my efforts
> to close (and clear) this window, I suspect that new memory is being
> allocated every time I want to draw on an OffScreenWindow. My
> suspicion is prompted by two factors: First, after many trials,
> Matlab is very slow at returning to the Command Window. Second, I
> put a counter in the while loop, responsible for maintaining each
> stimuli on the screen for a set amount of time. The number of
> iterations in this while loop decreases exponentially as the
> experiment progresses.
>
> How can I be sure that the memory for the OffScreenWindow is being
> cleared? Is there a difference between closing a window and clearing
> the memory used to draw the window? Are these even the right
> questions to be asking? (I can fake my way through Matlab, but I
> have no other programming experience.)
>
> Thanks,
> Jason
>
> PS - This experiment is being incorporated with an Eyelink 2.
> --
>
>
>
>
>
>
> Post your message to: psychtoolbox@yahoogroups.com
> Please indicate OS9, OSX, or WIN version, and include your full name.
> Denis Pelli, David Brainard, and Allen Ingling.
> http://psychtoolbox.org
>
> Yahoo! Groups Links
>
>
>
>
>
>
>