Django and/or psycopg memory leak
Make a simple task
@shared_task
def foo():
Event.objects.all().count()
for _ in range(50000): foo.delay()
Watch celery memory go up. top -p
pgrep -d "," celery`
Things that don't matter
- prefork, thread
- DEBUG is false
- CONN_MAX_AGE or not
- Python 3.11 vs 3.10
- Docker vs virt env
Workaround: Remove the psycopg-c package. The memory leak is gone.
Edited by David Burke