Skip to content

Instantly share code, notes, and snippets.

@JAEarly
Created May 3, 2020 13:30
Show Gist options
  • Save JAEarly/5d56d3eb6f2291f77a87197b5d96bc05 to your computer and use it in GitHub Desktop.
Save JAEarly/5d56d3eb6f2291f77a87197b5d96bc05 to your computer and use it in GitHub Desktop.
Python Demo: Logging Memory Usage
import resource
def log_memory_usage():
# On linux, defaults to KB
memory_usage_kb = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
# Convert to GB
memory_usage_gb = memory_usage_kb / 1000000
# Output
print("Memory Usage: {:.3f}GB".format(memory_usage_gb))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment