Last active
August 29, 2015 14:13
-
-
Save cluther/efc408ea43116712b9d5 to your computer and use it in GitHub Desktop.
Looking in the manhole for memory leaks..
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 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 |
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
| 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