mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-05 13:13:38 +02:00
Add testing for leaks in the windows pnp scanner
This commit is contained in:
parent
bcf5a4acfb
commit
7bba2267b0
1 changed files with 17 additions and 1 deletions
|
|
@ -338,7 +338,7 @@ def test_for_mem_leak():
|
|||
memory() # load the psutil library
|
||||
for i in xrange(3): gc.collect()
|
||||
|
||||
for reps in (1, 10, 100, 1000, 10000):
|
||||
for reps in (1, 10, 100, 1000):
|
||||
for i in xrange(3): gc.collect()
|
||||
h1 = gc_histogram()
|
||||
startmem = memory()
|
||||
|
|
@ -352,6 +352,22 @@ def test_for_mem_leak():
|
|||
diff_hists(h1, gc_histogram())
|
||||
prints()
|
||||
|
||||
if not iswindows:
|
||||
return
|
||||
|
||||
for reps in (1, 10, 100, 1000):
|
||||
for i in xrange(3): gc.collect()
|
||||
h1 = gc_histogram()
|
||||
startmem = memory()
|
||||
for i in xrange(reps):
|
||||
win_pnp_drives()
|
||||
for i in xrange(3): gc.collect()
|
||||
usedmem = memory(startmem)
|
||||
prints('Memory used in %d repetitions of pnp_scan(): %.5f KB'%(reps,
|
||||
1024*usedmem))
|
||||
prints('Differences in python object counts:')
|
||||
diff_hists(h1, gc_histogram())
|
||||
prints()
|
||||
|
||||
def main(args=sys.argv):
|
||||
test_for_mem_leak()
|
||||
|
|
|
|||
Loading…
Reference in a new issue