I have a custom command that crunches jobs coming from a Postgresql table jobs.
Since the command is multi threaded the action of “picking up the job” (select oldest job with status ‘pending’ && setting status to ‘in progress’) was made atomic.
The jobs I’m executing for this test are empty methods so the leak can’t be there.
Using tracemalloc pip package, I tracked down the python file and line that is allocating memory without ever relasing it: postgresql/operations.py:222 (Django 2.0.0)
I also installed Django 3 thinking that could have been an old bug but even with this update the problem is still there: postgresql/operations.py:235 (Django 3.0.5)