# OutOfMemoryError when loading images at startup of sketch

**URL:** <https://discourse.processing.org/t/outofmemoryerror-when-loading-images-at-startup-of-sketch/16429>\
**Category:** Coding Questions\
**Created:** [December 15, 2019, 10:14pm UTC](https://discourse.processing.org/t/outofmemoryerror-when-loading-images-at-startup-of-sketch/16429 "2019-12-15T22:14:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim076](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@Tim076](https://discourse.processing.org/u/Tim076)\
**Post date:** [December 15, 2019, 10:14pm UTC](https://discourse.processing.org/t/outofmemoryerror-when-loading-images-at-startup-of-sketch/16429/1 "2019-12-15T22:14:05Z")

</div>

Hi all,  
My sketch throws an OutOfMemoryError when I try to run it. However I only try to load in a total of 9 images with a combined size of 5 MB. I also only call loadImage in setup so I’m not constantly loading images or anything. When I comment out the images the program runs fine so it’s also not the rest of the code that’s causing problems. I’ve already tried to increase the amount of available memory but that doesn’t help either.

Does anyone have an idea what might be causing this error?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [December 15, 2019, 10:25pm UTC](https://discourse.processing.org/t/outofmemoryerror-when-loading-images-at-startup-of-sketch/16429/2 "2019-12-15T22:25:48Z")

</div>

You mentioned the things I’d guessed first.

can you show your code?

Check the images on hard drive, maybe some wrong file extension or size?

restart PC

And welcome to the community and to this forum!

Regards, Chrisir

---

<div class="post-metadata">

**Author:** ![Tim076](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@Tim076](https://discourse.processing.org/u/Tim076)\
**Post date:** [December 15, 2019, 11:01pm UTC](https://discourse.processing.org/t/outofmemoryerror-when-loading-images-at-startup-of-sketch/16429/3 "2019-12-15T23:01:39Z")

</div>

I found the problem,

I had exported the images from adobe illustrator with a canvas size of 8000 x 8000 pixels, so while the file size wasn’t high, the images were very big. I exported them as 1920x1080 (the size of the actual images) and now everything works fine.
