1 year ago
#221449
ShadowTerror
How to limit physical memory in python3?
I am trying to limit the memory usage of a python script, so it gets killed if it exceeds a threshold.
I tried using resource.setrlimit
but the module seems to be limited.
resource.setrlimit(resource.RLIMIT_RSS,...)
doesn't seem to work on newer Linux kernels.
resource.setrlimit(resource.RLIMIT_AS,...)
works but it also counts virtual and shared memory, thus killing the process when it doesn't need to.
I need a solution that works directly in python, without using control groups or other tools.
Any way I might achieve this?
python
memory
limit
virtual-memory
0 Answers
Your Answer