I need to load large amounts of bitmaps into memory for display in a WPF app (using .net 4.0). Where I run into trouble is when I approach around 1,400MB of memory ( I am getting this from the process list in the task manager).
This same thing happens whether the app is run on a machine with 4GB of memory or 6GB (and some other configs that I do not have the details on). It is easy to test by reducing the images loaded and when it works on 1 machine then it works on them all, but when it crashes on one it also does on all.
When I reduce the image count and allow the app to load without causing the memory exception I can run multiple instances of the app (exceeding the 1.4GB of the single instance) without the problem so it appears to be some per instance limit or per instance error on my part.
I load the images as a BitmapImage and they are either stored in a List<BitmapImage>
or loaded into a List<byte[]>
where they are later used in a bunch of layered sequences (using a Writeablebitmap
)
The error occurrs when I load the images not while in use. In the repeatable case I load 600 640X640 images plus another 200-300 smaller images ranging from 100X100 to 200X200, although it appears to be an overall bit count that is the problem.
So my questions are:
*Is there some built in per process memory limit in a situation like this?
*Is there a better technique to load large amounts of image data into memory?
Thanks, Brian