-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory use increases continually over time when running uvicorn[standard] #13745
Comments
For completeness' sake I updated Docker Desktop to the following (latest) version, and have same result with the MRE:
|
Just as another minor update, it appears as though |
I updated the MRE. I'm less convinced the issue lies in docker versus the specific use case. :-P But I'll keep testing and ask for this issue to be reopened if I discover another related problem. |
i had the same problem, the problem seems to lie in the reload param when using a uvicorn instance, when handling it with gunicorn the reload flag can be left on true, i just removed it and it solved the problem |
Description
I'm deploying a Docker container that runs
uvicorn
. During my testing I came across unexpected behaviour. If Ipip install uvicorn[standard]
, then run my container, I see continually-increasing memory usage that looks a lot like a memory leak until I abort (see screenshot for memory usage over a period of about one hour). But if instead Ipip install uvicorn
, then my memory usage appears stable.Reproduce
docker build -t memory_leak:debug .
docker run memory_leak:debug
docker exec -it <container_name> /bin/bash
and using a tool liketop
I see memory use go up about 5-10 MB/second and it never decreases.
Expected behavior
MRE should not use noticeably more memory over time.
docker version
Client: Cloud integration: v1.0.35+desktop.4 Version: 24.0.6 API version: 1.43 Go version: go1.20.7 Git commit: ed223bc Built: Mon Sep 4 12:32:48 2023 OS/Arch: windows/amd64 Context: default Server: Docker Desktop 4.23.0 (120376) Engine: Version: 24.0.6 API version: 1.43 (minimum version 1.12) Go version: go1.20.7 Git commit: 1a79695 Built: Mon Sep 4 12:32:16 2023 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.22 GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca runc: Version: 1.1.8 GitCommit: v1.1.8-0-g82f18fe docker-init: Version: 0.19.0 GitCommit: de40ad0
docker info
Diagnostics ID
33C45366-87F7-42F4-BD08-3FFB73427284/20231019214035
Additional Info
I made a MRE here and asked a colleague to help test: https://github.com/vaughantnrc/docker-uvicorn-memory-leak
These are our observations:
ubuntu:22.04
Docker image as a base;python:3.11.6
Docker image as a base (I also tried3.11.5
andslim-bookworm
variants at different points);My version of docker is:
Python packages:
At this point I'm not sure if the issue would be in
uvicorn
or Docker. So far the issue has only occurred in Docker so I'm starting the discussion here, but I'd be happy to report a parallel issue inuvicorn
for further discussion... or even elsewhere if that's where the discussions lead.Potentially-related issues, pending further investigation:
The text was updated successfully, but these errors were encountered: