Created
April 8, 2021 13:40
-
-
Save AlexMikhalev/6c608c78d0f3317096d0b8a60ca47858 to your computer and use it in GitHub Desktop.
Check memory usage in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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