Skip to content

Commit

Permalink
Add a "Free pools" column to "heap cpython-allocators" output
Browse files Browse the repository at this point in the history
Indicate proportion of memory within the allocator that's
currently unused.

Ideally we'd also give stats comparing:
  - never touched
  - in use
  - freed
but for now we just show:
  avail / total
  • Loading branch information
davidmalcolm committed Feb 22, 2011
1 parent 2ea26b0 commit 77bf70e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions heap/cpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,13 @@ def __init__(self):

@need_debuginfo
def invoke(self, args, from_tty):
t = Table(columnheadings=('struct arena_object*', '256KB buffer location'))
t = Table(columnheadings=('struct arena_object*', '256KB buffer location', 'Free pools'))
for arena in ArenaObject.iter_arenas():
t.add_row([fmt_addr(arena.as_address()),
fmt_addr(arena.address)])
fmt_addr(arena.address),
'%i / %i ' % (arena.field('nfreepools'),
arena.field('ntotalpools'))
])
print 'Objects/obmalloc.c: %i arenas' % len(t.rows)
t.write(sys.stdout)
print
Expand Down
4 changes: 3 additions & 1 deletion selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,9 @@ def _impl_test_python(self, pyruntime, py3k):
# Verify that "cpython-allocators" works:
allocators_out = tables[0]
self.assertEquals(allocators_out.colnames,
('struct arena_object*', '256KB buffer location'))
('struct arena_object*',
'256KB buffer location',
'Free pools'))

# print allocators_out
# self.assertHasRow(allocators_out,
Expand Down

0 comments on commit 77bf70e

Please sign in to comment.