learner learner

learner learner

  • NA
  • 29
  • 155.8k

Load 1000 images in c# without out-of-memory exception

Jan 24 2012 1:43 AM
I want to add 1000 images (each size is (40 to 100) KB) in a panel at run time in a desktop application. At first user browses all the images and load them on a panel. When it loads images one after another then memory usage shown in the task manager increases rapidly and after a certain number of images it shows the "Out of Memory Exception". Where is the fault in my code?
Before loading the 700 images task manager shows 1.05 GB memory usage. After loading task manager shows 2.04 GB and 2 GB RAM overflows
// code are attached

But I have seen some applications that can load huge number of images and takes memory that is negligible, for example, "Batch Image Resizer"( http://www.jklnsoft.com/)
Before loading the 700 images task manager shows 1.05 GB memory usage. After loading task manager shows 1.06 GB
How does the application handle memory? What mechanism do they follow?


Development environment: C#.net framework 4, windows xp, Visual Studio 2010, RAM: 2 GB


Attachment: code.zip

Answers (1)