Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
rough memory situation snapshotting function
from os import popen
import logging
from uuid import uuid4
from magical_place import some_map_like_backing_store # Redis, memcached, database, whatever
except ImportError:
some_map_like_backing_store = {}
def make_memory_report():
return "\n****\n".join([
popen('ps auxww').read(),
def store_memory_report(label="unknown"):
key = 'memory_report_' + uuid4().hex
some_map_like_backing_store[key] = key, make_memory_report()
logging.debug('memory report: label=%s, key=%s', label, key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment