简体   繁体   中英

ram memory consumed after program exit

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?

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()

它可能是无限循环,也可能只是一些计算花费了太多时间,为了完整起见,请您发布代码?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM