Skip to content

Instantly share code, notes, and snippets.

@xiongnemo
Created April 21, 2022 02:50
Show Gist options
  • Save xiongnemo/28c71a8c34199baffe3a86b073e4b3c3 to your computer and use it in GitHub Desktop.
Save xiongnemo/28c71a8c34199baffe3a86b073e4b3c3 to your computer and use it in GitHub Desktop.
import code
from guppy import hpy
def show_memory_stat():
print("===== GC Count (0th, 1st, 2rd Gen) =====")
print(gc.get_count())
h = hpy()
heap = h.heap()
print("===== Heap =====")
print(heap)
print("===== Heap by Type =====")
print(heap.bytype)
print("===== Heap by Referers =====")
print(heap.byrcs)
print("===== Spawning REPL, send EOF (Ctrl + D on Linux) to quit =====")
code.InteractiveConsole(locals=locals()).interact()
del heap, h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment