Created
March 18, 2014 18:45
-
-
Save thobbs/9626691 to your computer and use it in GitHub Desktop.
Memory Leak Repro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?