Hi all
On my production environment my site tends to keep throwing an OutOfMemoryException related to ImageSharp and then the site annoyingly restarts itself.
I believe there’s a pattern of this occurring shortly after the site deploys each time, nothing out of the ordinary is in our build process. The site is running Umbraco 9.2 and is hosted in an Azure App Service. Images are also hosted in Azure Blog Storage.
Below is the stack trace of the error, let me know if anyone requires any further information but any thoughts would be appreciated.
"System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Buffers.ConfigurableArrayPool`1.Rent(Int32 minimumLength)
at SixLabors.ImageSharp.Memory.ArrayPoolMemoryAllocator.Allocate[T](Int32 length, AllocationOptions options)
at SixLabors.ImageSharp.Memory.MemoryGroup`1.Allocate(MemoryAllocator allocator, Int64 totalLength, Int32 bufferAlignment, AllocationOptions options)
at SixLabors.ImageSharp.Memory.MemoryAllocatorExtensions.AllocateGroup[T](MemoryAllocator memoryAllocator, Int64 totalLength, Int32 bufferAlignment, AllocationOptions options)
at SixLabors.ImageSharp.Memory.MemoryAllocatorExtensions.Allocate2D[T](MemoryAllocator memoryAllocator, Int32 width, Int32 height, AllocationOptions options)
at SixLabors.ImageSharp.ImageFrame`1..ctor(Configuration configuration, ImageFrame`1 source)
at SixLabors.ImageSharp.ImageFrame`1.Clone(Configuration configuration)
at SixLabors.ImageSharp.ImageFrameCollection`1.AddFrame(ImageFrame`1 source)
at SixLabors.ImageSharp.Formats.Gif.GifDecoderCore.ReadFrameColors[TPixel](Image`1& image, ImageFrame`1& previousFrame, Buffer2D`1 indices, ReadOnlySpan`1 colorTable, GifImageDescriptor& descriptor)
at SixLabors.ImageSharp.Formats.Gif.GifDecoderCore.ReadFrame[TPixel](Image`1& image, ImageFrame`1& previousFrame)
at SixLabors.ImageSharp.Formats.Gif.GifDecoderCore.Decode[TPixel](BufferedReadStream stream, CancellationToken cancellationToken)
at SixLabors.ImageSharp.Formats.ImageDecoderUtilities.Decode[TPixel](IImageDecoderInternals decoder, Configuration configuration, Stream stream, Func`3 largeImageExceptionFactory)
at SixLabors.ImageSharp.Formats.ImageDecoderUtilities.Decode[TPixel](IImageDecoderInternals decoder, Configuration configuration, Stream stream)
at SixLabors.ImageSharp.Formats.Gif.GifDecoder.Decode[TPixel](Configuration configuration, Stream stream)
at SixLabors.ImageSharp.Image.Decode[TPixel](Stream stream, Configuration config)
at SixLabors.ImageSharp.Image.<>c__DisplayClass133_0`1.<Load>b__0(Stream s)
at SixLabors.ImageSharp.Image.WithSeekableStream[T](Configuration configuration, Stream stream, Func`2 action)
at SixLabors.ImageSharp.Image.Load[TPixel](Configuration configuration, Stream stream, IImageFormat& format)
at SixLabors.ImageSharp.Web.FormattedImage.Load(Configuration configuration, Stream source)
at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.<>c__DisplayClass19_0.<<ProcessRequestAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.<>c__DisplayClass19_0.<<ProcessRequestAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at SixLabors.ImageSharp.Web.Middleware.ConcurrentDictionaryExtensions.GetOrAddAsync[TKey,TValue](ConcurrentDictionary`2 dictionary, TKey key, Func`2 valueFactory)
at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.ProcessRequestAsync(HttpContext context, IImageResolver sourceImageResolver, ImageContext imageContext, IDictionary`2 commands)
at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 119
at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Umbraco.Cms.Web.Common.Middleware.PreviewAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestLoggingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()"
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/108670-outofmemoryexception-on-imagesharp