Carlos Alexandro Becker <caarl...@gmail.com> added the comment:
Just did more tests here: **on my machine**: $ docker run --name test -m 1GB fedora:33 python3 -c 'import resource; m = int(open("/sys/fs/cgroup/memory/memory.limit_in_bytes").read()); resource.setrlimit(resource.RLIMIT_AS, (m, m)); print(resource.getrlimit(resource.RLIMIT_AS)); x = bytearray(4 * 1024 * 1024 * 1000)'; docker inspect test | grep OOMKilled; docker rm test Traceback (most recent call last): File "<string>", line 1, in <module> MemoryError (1073741824, 1073741824) "OOMKilled": false, test $ docker run --name test -m 1GB fedora:33 python3 -c 'x = bytearray(4 * 1024 * 1024 * 1000)'; docker inspect test | grep OOMKilled; docker rm test "OOMKilled": true, test **on a k8s cluster**: $ kubectl run -i -t debug --rm --image=fedora:33 --restart=Never --limits='memory=1Gi' If you don't see a command prompt, try pressing enter. [root@debug /]# python3 Python 3.9.0 (default, Oct 6 2020, 00:00:00) [GCC 10.2.1 20200826 (Red Hat 10.2.1-3)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> x = bytearray(4 * 1024 * 1024 * 1000) Killed [root@debug /]# python3 Python 3.9.0 (default, Oct 6 2020, 00:00:00) [GCC 10.2.1 20200826 (Red Hat 10.2.1-3)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import resource >>> m = int(open("/sys/fs/cgroup/memory/memory.limit_in_bytes").read()) >>> resource.setrlimit(resource.RLIMIT_AS, (m, m)) >>> print(resource.getrlimit(resource.RLIMIT_AS)) (1073741824, 1073741824) >>> x = bytearray(4 * 1024 * 1024 * 1000) Traceback (most recent call last): File "<stdin>", line 1, in <module> MemoryError >>> ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42411> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com