New submission from Adrian Teng: A particular usage pattern of hashlib will cause a memory leak.
This leaks: import hashlib import sys if __name__ == '__main__': data_sha1 = "hello world" data_md5 = "hello world" for i in xrange(int(1e6)): hashlib.sha1(data_sha1) hashlib.md5(data_md5) if i % 1000 == 0: print sys.getrefcount(data_sha1), ",", sys.getrefcount(data_md5) ------- this doesn't leak: import hashlib import sys if __name__ == '__main__': data_sha1 = "hello world" data_md5 = "hello world" for i in xrange(int(1e6)): sha1 = hashlib.sha1() sha1.update(data_sha1) md5 = hashlib.md5() md5.update(data_md5) if i % 1000 == 0: print sys.getrefcount(data_sha1), ", ", sys.getrefcount(data_md5) See attached for leak memory profiling in linux ---------- components: Library (Lib) files: memoryleak_min.py messages: 213961 nosy: ateng priority: normal severity: normal status: open title: hashlib memory leak type: resource usage versions: Python 2.7 Added file: http://bugs.python.org/file34489/memoryleak_min.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20967> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com