Skip to content

Instantly share code, notes, and snippets.

@AlexMikhalev
Created April 8, 2021 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexMikhalev/6c608c78d0f3317096d0b8a60ca47858 to your computer and use it in GitHub Desktop.
Save AlexMikhalev/6c608c78d0f3317096d0b8a60ca47858 to your computer and use it in GitHub Desktop.
Check memory usage in python
#standard module
# peak memory usage (kilobytes on Linux, bytes on OS X)
import resource
resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
# pip install psutil
import os, psutil; print(psutil.Process(os.getpid()).memory_info().rss / 1024 ** 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment