Skip to content

Instantly share code, notes, and snippets.

@willb
Forked from anonymous/mem leak test script
Created October 5, 2011 12:13
Show Gist options
  • Save willb/1264302 to your computer and use it in GitHub Desktop.
Save willb/1264302 to your computer and use it in GitHub Desktop.
leaky.py
Partition of a set of 702256 objects. Total size = 93752736 bytes.
Index Count % Size % Cumulative % Kind (class / dict of class)
0 28141 4 29491768 31 29491768 31 dict of qmf.console.Object
1 56293 8 15762040 17 45253808 48 dict of qmf.console.ObjectId
2 180702 26 13130552 14 58384360 62 tuple
3 85356 12 10054240 11 68438600 73 list
4 136839 19 7397808 8 75836408 81 str
5 56625 8 6191896 7 82028304 87 unicode
6 56293 8 4053096 4 86081400 92 qmf.console.ObjectId
7 28141 4 1801024 2 87882424 94 qmf.console.Object
8 56772 8 1362528 1 89244952 95 int
9 144 0 450432 0 89695384 96 dict of module
from qmf.console import Session
import datetime
from guppy import hpy
hp=hpy()
# create a new console object
console = Session()
# connect to the broker (on localhost:5672, by default)
console.addBroker()
def main():
import cProfile
for i in xrange(10):
print "%d" % i
cProfile.runctx('getNodes()', globals(), locals(), "getnodes.txt")
def getNodes():
print "\nGetting nodes from wallaby store"
start()
nodes = console.getObjects(_class="Node")
now = datetime.datetime.now()
end()
print "The nodes have been fetched"
def start():
now = datetime.datetime.now()
print "Start: %d:%02d.%d" % (now.minute, now.second, now.microsecond)
def end():
now = datetime.datetime.now()
print "End: %d:%02d.%d" % (now.minute, now.second, now.microsecond)
if __name__ == "__main__":
main()
print hp.heap()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment