Message213961
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 |
|
Date |
User |
Action |
Args |
2014-03-18 14:03:55 | ateng | set | recipients:
+ ateng |
2014-03-18 14:03:55 | ateng | set | messageid: <1395151435.82.0.675671732533.issue20967@psf.upfronthosting.co.za> |
2014-03-18 14:03:55 | ateng | link | issue20967 messages |
2014-03-18 14:03:55 | ateng | create | |
|