Bitmap image load chews up a lot of memory

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

There seems to be a memory leak problem in loading an image in .NET

I am trying to load up an image, which is 1MB in size on the disk. When I load up the image it expands out to atleast 25MB in memory. THIS cannot be right!!

The line of code I am using is:

"formImage = new Bitmap("Form.jpg");"

Does anyone know a fix around this?? Please help.
 
JPG images are compressed, but when an image is loaded in an app it needs to
allocate the memory required for the pixel data. For example, I took a
screenshot of my desktop (a 24-bit image at 1400x1050) and saved it as a
jpg, which resulted in a 51KB file. However, when I open it in Paint, the
memory required to keep the image in memory is 3 x 1400 x 1050 = 4.5MB. For
some reason Paint actually ends up using 18MB, but I guess that's a topic
for another thread :-)
 
Back
Top