# Image stimulus memory usage

**URL:** <https://mworks.discourse.group/t/image-stimulus-memory-usage/43>\
**Category:** Stimuli\
**Created:** [April 30, 2018, 3:11pm UTC](https://mworks.discourse.group/t/image-stimulus-memory-usage/43 "2018-04-30T15:11:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [April 30, 2018, 3:11pm UTC](https://mworks.discourse.group/t/image-stimulus-memory-usage/43/1 "2018-04-30T15:11:29Z")

</div>

The memory requirements of an experiment that loads a large number of [image stimuli](https://mworks.github.io/documentation/latest/components/image_stimulus.html) 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](https://mworks.github.io/documentation/latest/components/load_stimulus.html) action, before queuing it as usual. When you no longer need the image, unload it with the [Unload Stimulus](https://mworks.github.io/documentation/latest/components/unload_stimulus.html) 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](https://mworks.discourse.group/t/image-loading-limits/712/5) 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.

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 20, 2022, 4:03pm UTC](https://mworks.discourse.group/t/image-stimulus-memory-usage/43/2 "2022-07-20T16:03:41Z")

</div>


