I'm getting an OutOfMemory Exception when trying to resize larger images. Our server can only resize images of less then 1000x1000 pixels. My development machine seems too handle any size, and other developer machines seem to have the same limitations as the server. My development machine is also the best spec'd.
I feel like this code properly disposes of all the objects, but i could be wrong. I've tried using perfmon to view the .Net CLR memory but I'm unsure of how to interpret the results.
I'm stuck as to how to best solve this problem and get a definitive answer on why the problem exists. Any debugging ideas would be greatly appreciated.
Edit: Error occurs on g.DrawImage
using(Image imgToResize = Image.FromFile(path))
{
using (Bitmap b = new Bitmap(ResizeWidth, ResizeHeight, PixelFormat.Format24bppRgb))
{
using(Graphics g = Graphics.FromImage(b))
{
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(imgToResize, 0, 0, ResizeWidth, ResizeHeight);
b.Save(DiskPathThumb(maxSize), ImageFormat.Jpeg);
}
}
}
g.DrawImage, the resize value will usually be quite small. Maybe between 100-300px.OutOfMemoryexception if the parameters are invalid. Though I can't see how that can happen in your code. Since your parameters seem to be always valid. And the doc for your overload ofDrawImagessays nothing about that either.