Skip to content

Memory usage always increasing when resizing over and over #526

@mabead

Description

@mabead

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Description

Running image sharp on multiple images causes memory to increase up to 1.5 GB

Steps to Reproduce

I have the following code that is hosted in an AWS lambda.

        // This is a member function of my PictureProvider class
        public void Resize(Stream sourceStream, string target, int newWidth, int newHeight)
        {
            using (var image = Image.Load(sourceStream))
            using (var outputFile = File.OpenWrite(target))
            {
                image.Mutate(ctx => ctx.Resize(newWidth, newHeight));
                image.SaveAsJpeg(outputFile);
            }
        }

This code has been used since this morning in production by our web site where our users upload their own image that can range from 1500x1500 to 6000x6000 in JPEG and PNG format.

When I look at the AWS lambda execution logs, I see the following:

image

As you can see the memory consumed by the lambda only keeps on increasing... until it reaches the 1500 MB that I allocated to the lambda. At this point the lambda dies and AWS instantiates a new fresh container for the lambda.

Here's what I intent to do: I will try to replace the default memory manager by the SimpleGcMemoryManager which is not supposed to pool memory as indicated here. Let me know if you have any other suggestion.

System Configuration

  • ImageSharp version:1.0.0-beta0003
  • Environment (Operating system, version and so on): AWS lambda running on dotnet core 2.0 on linux
  • .NET Framework version: netcoreapp2.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions