Skip to content

Instantly share code, notes, and snippets.

@harlowja
Last active February 7, 2017 00:33
Show Gist options
  • Save harlowja/0d35e8887126a6b5e78ef96452b7bfe5 to your computer and use it in GitHub Desktop.
Save harlowja/0d35e8887126a6b5e78ef96452b7bfe5 to your computer and use it in GitHub Desktop.
import os
import sys
import tracemalloc
import pickle
if __name__ == '__main__':
for fn in sys.argv[1:]:
print("Dumping " + fn)
with open(fn, 'rb') as fh:
snapshot = pickle.load(fh)
stats = snapshot.statistics('traceback')
for i, stat in enumerate(stats[0:10]):
print(" Index = %s" % i)
print(" Size = %sb/%skb/%smb" % (stat.size, stat.size/1024, stat.size/(1024**2)))
print(" Count = %s" % stat.count)
print(" Traceback:")
for line in stat.traceback.format():
print(" " + line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment