This project is read-only.

Memory Management

Nov 6, 2007 at 5:16 PM
One of the problems with the .NET bitmap class is that it explodes the file size in memory. 1.5 MB may go up to 22 MB in memory. I have had out of memory exceptions in shared hosting environments using the approach in this handler. Are there any open source libraries that will give you image dimensions and sizing options without loading the entire rasterized image in memory?
Jul 28, 2011 at 10:38 AM

Hi jedatu,

I try to fix the problem of memory and I will put in a few days a new version of the code.

Thank you.

Aug 8, 2011 at 3:25 PM
Edited Aug 8, 2011 at 3:26 PM

@jedatu - Only certain image formats support partial decoding - jpegs compressed progressively, for example, can be decoded partially without loading the entire image into memory.

With .NET, there isn't a way to avoid decompressing the entire image unless you use the embedded thumbnail (which is only present is some images, and can be 20px by 20px small).

The problem behind most OutOfMemoryExceptions is usually either (a) Using clauses weren't used properly, causing leaked bitmaps, (b) you're trying to resize a 20MP image on a shared server, or (b), you're not using disk caching.

I wrote an article on the common bugs in image resizing systems - it might be worth a read.

@lorenzobattaglia - It's good to see the project is getting active again. However, why not merge with the project like many other projects are doing? I just finished adding an adaptor that allows you to use the same URL syntax you're used to - no need to alienate users or make extra work for yourself. Shoot me an e-mail, let's discuss it.

I'm trying to get all the authors of various image resizing scripts to start working together instead of "re-inventing the wheel" over and over. Running a one-man open-source project kind of defeats the purpose, don't you think?