Memory leak debug – Python script running on Heroku

I am running a python script that is invoked through a simple Flask application. I am running this on Heroku.
Here is the workflow – Invoking a url in the Flask app triggers the python script using asyncio(this is required to let flask request return gracefully after triggering the script. Script continues executing for a couple of hours

Now when I check the logs on Heroku, memory keeps increasing. I used tracemalloc inside the script and saw that the memory usage is flat..
But when I monitor the Heroku logs, Memory keeps increasing continuously.

What is the best way to debug this. Any pointers will be helpful

Source: Python Questions

LEAVE A COMMENT