Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 79d2892

Browse files
committed
Added option (-c) to display cycles including uncollectable garbage.
Displays the total number of Python objects in existence at each iteration. svn path=/trunk/matplotlib/; revision=3451
1 parent c26a2a9 commit 79d2892

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

unit/memleak_gui.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
parser.add_option("-d", "--backend", dest="backend",
3535
default='',
3636
help="backend")
37-
37+
parser.add_option("-c", "--cycles", dest="cycles",
38+
default=False, action="store_true")
3839

3940
options, args = parser.parse_args()
4041

@@ -47,6 +48,8 @@
4748
import pylab
4849
import matplotlib.cbook as cbook
4950

51+
print indEnd
52+
5053
for i in range(indEnd+1):
5154

5255
fig = pylab.figure()
@@ -57,7 +60,8 @@
5760
val = cbook.report_memory(i)
5861
if options.verbose:
5962
if i % 10 == 0:
60-
print i, val
63+
print ("iter: %4d OS memory: %8d Python objects: %8d" %
64+
(i, val, len(gc.get_objects())))
6165
if i==indStart: start = val # wait a few cycles for memory usage to stabilize
6266

6367
gc.collect()
@@ -73,3 +77,5 @@
7377
print '# Memory went from %dk to %dk' % (start, end)
7478
print '# Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart))
7579

80+
if options.cycles:
81+
cbook.print_cycles(gc.garbage)

0 commit comments

Comments
 (0)