Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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