I have a python program on which I wanted to set memory limits with setrlimit. But after setting the RLIMIT_AS, some things will stop working: calling subprocesses making http requests def main(): # resource.setrlimit(resource.RLIMIT_AS, (1024 *1000, 1024*1000)) print(requests.get('https://api.github.com').json()) print(subprocess.Popen(['which', 'wkhtmltopdf'], stdout=subprocess.PIPE).communicate()[0]) If the setrlimit is called, the requests.get() hangs, and the subprocess.popen call fails with: /bin/sh: error while loading shared libraries: libc.so.6: failed to map segment from shared object What is the reason for this? Can I work around this problem? I am actually running this inside kubernetes/docker/python:3.10.5 Linux version 6.1.129-vsh0zfs227 (root@...) (gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0, GNU ld (GNU Binutils for Ubuntu) 2.42) #4 SMP PREEMPT_DYNAMIC Sun Mar 2 00:56:57 UTC 2025. The kubernetes deployment has memory limits set already (so cgroup memory.max is set), but I wanted to handle MemoryError-s in python instead of getting random sigkills on my containers. Continue reading...