U4-3844 - U7 - System.OutOfMemoryException: Out of memory - uploading 11Mb image

Created by Jeavon Leopold 12 Dec 2013, 10:47:07 Updated by wtct 07 Nov 2016, 09:15:39

When uploading a 11Mb image in Umbraco v7.0.1 I get the following exception: Out of memory.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.OutOfMemoryException: Out of memory.

Stack Trace:

at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData) at System.Drawing.Image.FromStream(Stream stream) at Umbraco.Web.PropertyEditors.FileUploadPropertyValueEditor.ConvertEditorToDb(ContentPropertyData editorValue, Object currentValue) at Umbraco.Web.Editors.ContentControllerBase.MapPropertyValues[TPersisted](ContentBaseItemSave1 contentItem) at Umbraco.Web.Editors.MediaController.MapPropertyValues[TPersisted](ContentBaseItemSave1 contentItem) at Umbraco.Web.Editors.MediaController.PostSave(MediaItemSave contentItem) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.b__c(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.b__4() at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)

1 Attachments


Shannon Deminick 13 Dec 2013, 04:16:51

How are you uploading the image?

Shannon Deminick 13 Dec 2013, 04:27:10

I've tried with a 10.5 mb image on both the upload prop editor and the drag drop way and it seems to work. Will try with a huge one.

Shannon Deminick 13 Dec 2013, 04:30:08

Ok, can replicate with a 14mb one, will investigate

Shannon Deminick 13 Dec 2013, 04:41:22

TBH, it's probably an issue in 6.2 as well.

Shannon Deminick 13 Dec 2013, 05:31:08

It would seem that when an image is rather large and you are scaling it that the setting:


has a large affect on the processing. This is the 'best' interpolation setting and that is what we use which works fine until the images are huge and we get the out of mem exception. Turns out that GDI+ is riddled with out of mem exceptions but almost none of them are actually related to being out of memory. However in this case it might be exceeding the max individual mem stack for this process.

The other three quality params that we use:

SmoothingMode.HighQuality; PixelOffsetMode.HighQuality; CompositingQuality.HighQuality;

probably also play a factor in this but with a 15 mb image leaving those as high quality still works (not sure what would happen if you got really huge though).

So now i'll just detect if your original image is bigger than either 5000px high or wide and if so use the mid level interpolation.

Here's a good interpololation ref: http://msdn.microsoft.com/en-us/library/k0fsyd4e(v=vs.110).aspx

Shannon Deminick 13 Dec 2013, 05:35:23

Another good article: http://weblogs.asp.net/bleroy/archive/2007/12/05/what-interpolationmode-and-compositingquality-to-use-when-generating-thumbnails-via-system-drawing.aspx

Dan White 09 Jan 2015, 00:36:44

I'm getting similar errors in 7.2.1. The image is 17.4mb and 11608 x 9061.

Shannon Deminick 09 Jan 2015, 02:02:51

Might have to run more detection on image sizes and change one of those parameters above. You'll need to open up another issue with steps to reproduce.

wtct 07 Nov 2016, 09:15:39


We had similar problem in 6.2.6 with jpg like this: 8 MB, 4608x3456, 72 dpi, 24 bits, sRGB. Take a look at attachment.

This image uploaded properly after App Pool recycled.

App Pool before restar was about 1.2 GB but on the server RAM was still available.

Maybe there is any memory leakage?

Error Log:

2016-11-07 09:43:31,593 [79] ERROR umbraco.presentation.umbraco.webservices.MediaUploader - [Thread 192] Error uploading to parent 418612 System.OutOfMemoryException: Out of memory. at System.Drawing.Graphics.CheckErrorStatus(Int32 status) at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData) at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit) at Umbraco.Core.Models.ContentExtensions.GenerateThumbnail(MediaFileSystem fileSystem, Image image, Int32 maxWidthHeight, String extension, String thumbnailFileName, Boolean useFixedDimensions) at Umbraco.Core.Models.ContentExtensions.Resize(MediaFileSystem fileSystem, String path, String extension, Int32 maxWidthHeight, String fileNameAddition, Image originalImage) at Umbraco.Core.Models.ContentExtensions.SetFileOnContent(IContentBase content, String propertyTypeAlias, String name, Stream fileStream) at umbraco.cms.businesslogic.media.UmbracoImageMediaFactory.DoHandleMedia(Media media, PostedMediaFile postedFile, User user) at umbraco.cms.businesslogic.media.UmbracoMediaFactory.HandleMedia(Int32 parentNodeId, PostedMediaFile postedFile, User user) at umbraco.presentation.umbraco.webservices.MediaUploader.ProcessUploadRequest(HttpContext context)

Priority: Normal

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 7.0.0, 7.0.1

Due in version: 7.0.2


Story Points: