1

I have a program that I want to run in python on about 20 cores (for a research math question) but the code has a bit of a memory leak. It is ok running small batches of this code but I would really like to just let it run on these cores for say a couple weeks. Is there any way in Python to build in an automatic restart or something to avoid the long-term memory issues? Delete function does not help. Any help is appreciated!

Adam Martens
  • 111
  • 4
  • If I understand well, you have a kind of Python service/daemon that performs calculations and you want to restart it. If it is a service, why not killing it and restart it in a cron? – Laurent LAPORTE May 25 '18 at 03:40

2 Answers2

1

first, persistent your compute status and result, then write a detect function to detect the memory leak, stop the program, using supervisor or pm2 to restart it.

Xiaoyu Xu
  • 858
  • 6
  • 5
1

You can have a script that just starts and kills other python processes, but that seems like a weak workaround for your memory leak.

Take a look at this SO answer for debugging python memory leaks

rsiemens
  • 615
  • 6
  • 15