Image stimulus memory usage

The memory requirements of an experiment that loads a large number of image stimuli can exceed available main memory (RAM) or video memory (VRAM). When this happens, there are a number of steps you can take to reduce your experiment’s memory footprint.

Use smaller images

Reducing the size (in pixels) of an image reduces the amount of memory it consumes, so you can limit your experiment’s memory requirements by scaling down your images.

Manage image loading/unloading explicitly

By default, MWorks loads all images during experiment parsing and keeps them in memory until the experiment is closed. However, it is possible to override this behavior and control the loading and unloading of images explicitly.

To prevent MWorks from loading an image at parse time, add deferred="explicit" to the stimulus definition. Then, when you want to display the image, load it with the Load Stimulus action, before queuing it as usual. When you no longer need the image, unload it with the Unload Stimulus action.

Note that the time required to load an image is often substantial and can impact the timing of your experiment significantly. (See this discussion for some example load times.)

Run the server in 64-bit mode

Only applicable to pre-0.7 releases

When MWServer runs as a 32-bit process, it is limited to a maximum of 4GB of RAM. Running the server in 64-bit mode removes this limitation.

Turn off the mirror window

Only applicable to pre-0.6 releases

When using the mirror window, MWorks 0.5.1 and earlier load every image twice: once for the main display, and once for the mirror window. Therefore, turning the mirror window off will cut your experiment’s image memory usage in half.