Skip to content

rpi-02w: High memory usage when caching large images in Utils().thumbnail causes uvicorn to be killed #1

Description

@remohexa

When Utils().thumbnail tries to cache an image whose raw data is large enough, the kernel just terminates the whole uvicorn process due to insufficient memory.

After some inspection, it turned out that I never properly closed the PIL image or the buffer after opening an image, which may take up extra memory (perhaps, I’m not really that good with memory related stuff).

And the root cause is actually related to how large some images can be when dealing with their uncompressed versions. Since PIL works with the raw data of images, a 9MB image can go all the way up to >100MB in memory.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions