Reputation: 11419
I have an image file that is 6 mb on disk.
When I load it using
Dim nBmp As Bitmap = Bitmap.FromFile(sPath)
... TaskManager shows an increase of used RAM of my app of around 200 mb.
I could confirm this because if I do this around 6 times, the RAM goes up to 1,2 GB, and further attempts to do that raise an out-of-memory error.
So it's actually true that so much is being used. I don't process this bitmap any further.
Why is the bitmap so much larger than the file on the disk?
Upvotes: 0
Views: 282
Reputation: 901
You are loading an compressed image. PNG in your case. The Bitmap.FromFile
will decompress it and then load it into memory as uncompressed Bitmap. Which needs much more space. As you said in the comment: 6MB as PNG and 190MB as Bitmap.
Upvotes: 3