In order to investigate some issues with unreleased system resources I'd like to force immediate garbage collection on an already running python script.
Is this somehow possible, e.g. by sending some kind of signal that Python would understand as an order to run gc; or any other similar way? Thanks.
I'm running Python 2.7 on a Linux server.
Install a signal handler using the built-in signal module, then call gc.collect() from your custom handler.
If you have no control over the application, you'll have to use something like pyringe, which will allow you to insert arbitrary python.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With