Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Harlow 3 posts 23 karma points
    Mar 31, 2022 @ 10:34
    David Harlow
    0

    OutOfMemoryException on ImageSharp

    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()"
    
  • Bartosz Szadach 13 posts 77 karma points
    18 days ago
    Bartosz Szadach
    0

    Hi! Have you found any solution for this problem? Have the same on umbraco 13.1.0.

  • David Harlow 3 posts 23 karma points
    17 days ago
    David Harlow
    0

    Hey! If memory serves me right then yes this was as a result of as very large GIF file that was being indexed every time we deployed the site, removing this file solved the problem

  • Søren Kottal 711 posts 4549 karma points MVP 6x c-trib
    18 days ago
    Søren Kottal
    0

    How big is the image you are trying to handle with ImageSharp? The stack trace suggests it's a gif. If it's a gif that should have been a video, then the filesize might be huge.

  • Bartosz Szadach 13 posts 77 karma points
    17 days ago
    Bartosz Szadach
    0

    So, it's likely that a large (4.5MB) file is causing the issue in my case as well. Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft