Skip to content

Instantly share code, notes, and snippets.

@thobbs
Created March 18, 2014 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thobbs/9626691 to your computer and use it in GitHub Desktop.
Save thobbs/9626691 to your computer and use it in GitHub Desktop.
Memory Leak Repro
import resource
import gc
from guppy import hpy
def print_heap(hp):
h = hp.heap()
strs = []
strs.extend(str(h).split('\n')[1:-1])
for i in range(10):
h = h.more
if not h:
break
strs.extend(str(h).split('\n')[1:-1])
del h
print '\n'.join(strs)
def main():
hp = hpy()
from cassandra.io.libevreactor import LibevConnection
connection = LibevConnection.factory()
connection.close()
hp.setrelheap()
for i in xrange(100):
connection = LibevConnection.factory()
connection.close()
gc.collect()
print_heap(hp)
print resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
if __name__ == "__main__":
main()
@Terryhung
Copy link

I have some problem, when I use this code.
ImportError: The C extension needed to use libev was not found. This probably means that you didn't have the required build dependencies when installing the driver. See http://datastax.github.io/python-driver/installation.html#c-extensions for instructions on installing build dependencies and building the C extension.

what should I do if I have no root?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment