Skip to content

Instantly share code, notes, and snippets.

@embano1
Last active March 18, 2019 10:27
Show Gist options
  • Save embano1/8b28078ebf690c74b20ebf239ae83e5d to your computer and use it in GitHub Desktop.
Save embano1/8b28078ebf690c74b20ebf239ae83e5d to your computer and use it in GitHub Desktop.
Python OOM Docker Quick'n'Dirty

Run container with 200M MEM limit and swap off

docker run -it -m 200M --memory-swap 0 python

Now run ctop with single container view to see mem usage increasing

ctop // switch to single container view

Now allocate some bytes

>>> a = bytearray(1024*1024*50) // 50M
>>> a.extend(bytearray(1024*1024*200)) // Add 200M -> OOM
<OOM_Killer>

Verify it was the OOM_Killer

docker inspect c3061d12b078| jq '.[].State.OOMKilled'
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment