Skip to content

Instantly share code, notes, and snippets.

@cluther
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save cluther/efc408ea43116712b9d5 to your computer and use it in GitHub Desktop.

Select an option

Save cluther/efc408ea43116712b9d5 to your computer and use it in GitHub Desktop.
Looking in the manhole for memory leaks..
import gc, sys
objs = []
for obj in gc.get_objects():
size = sys.getsizeof(obj, 0)
if size > 1024:
objs.append((obj, size))
objs.sort(key=lambda x: x[1], reverse=True)
from pprint import pprint
print len(objs) # total objects
print objs[0][1] # largest object size
pprint(objs[0][0]) # largest object
print objs[1][1] # second largest object size
pprint(objs[1][0]) # second largest object
diff --git a/ZenPacks/zenoss/PythonCollector/zenpython.py b/ZenPacks/zenoss/PythonCollector/zenpython.py
index 1f31940..e6e9196 100644
--- a/ZenPacks/zenoss/PythonCollector/zenpython.py
+++ b/ZenPacks/zenoss/PythonCollector/zenpython.py
@@ -315,4 +315,10 @@ def main():
if __name__ == '__main__':
+ import twisted.manhole.telnet
+ f = twisted.manhole.telnet.ShellFactory()
+ f.username, f.password = ('zenoss', 'zenoss')
+ reactor.listenTCP(7777, f)
+
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment