I am running a python script on linux terminal. The script has an infinite calculus loop and it never ends, so for now I'm stopping it with ctrl+C. After that, all the ram memory consumed by the program (which is a lot, and I don't find the leakage yet) is still consumed, until the moment I close the terminal. What can be happening?
Asked
Active
Viewed 88 times
0
-
Does it spawn any subprocesses? What program is identified as owning that memory? – John Gordon May 07 '18 at 19:06
-
Please post minimal verifiable complete example: https://stackoverflow.com/help/mcve – zython May 07 '18 at 19:10
2 Answers
3
I would suggest using a combination of: How do I capture SIGINT in Python? and How can I explicitly free memory in Python?
#!/usr/bin/env python
import signal
import sys
import gc
def signal_handler(signal, frame):
print('Cleaning up...')
gc.collect()
print('Bye.')
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
signal.pause()

Hezi Shahmoon
- 388
- 1
- 7
0
it may be an infinte loop or just some calculations that took too much time, for the sake of completeness, can you please post your code?

Mohammed Janati Idrissi
- 404
- 4
- 13