[pypy-svn] r68762 - pypy/branch/gc-dump-heap/pypy/module/gc
fijal at codespeak.net
fijal at codespeak.net
Mon Oct 26 17:56:12 CET 2009
Author: fijal
Date: Mon Oct 26 17:56:12 2009
New Revision: 68762
Modified:
pypy/branch/gc-dump-heap/pypy/module/gc/__init__.py
pypy/branch/gc-dump-heap/pypy/module/gc/interp_gc.py
Log:
A dump_heap operation, no test so far
Modified: pypy/branch/gc-dump-heap/pypy/module/gc/__init__.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/module/gc/__init__.py (original)
+++ pypy/branch/gc-dump-heap/pypy/module/gc/__init__.py Mon Oct 26 17:56:12 2009
@@ -12,4 +12,5 @@
'disable_finalizers': 'interp_gc.disable_finalizers',
'estimate_heap_size': 'interp_gc.estimate_heap_size',
'garbage' : 'space.newlist([])',
+ 'dump_heap': 'interp_gc.dump_heap',
}
Modified: pypy/branch/gc-dump-heap/pypy/module/gc/interp_gc.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/module/gc/interp_gc.py (original)
+++ pypy/branch/gc-dump-heap/pypy/module/gc/interp_gc.py Mon Oct 26 17:56:12 2009
@@ -1,6 +1,7 @@
from pypy.interpreter.gateway import ObjSpace
from pypy.interpreter.error import OperationError
from pypy.rlib import rgc
+from pypy.rlib.streamio import open_file_as_stream
def collect(space):
"Run a full collection."
@@ -52,3 +53,13 @@
raise OperationError(space.w_RuntimeError,
space.wrap("can't estimate the heap size"))
estimate_heap_size.unwrap_spec = [ObjSpace]
+
+def dump_heap(space, filename):
+ tb = rgc._dump_heap()
+ f = open_file_as_stream(filename, mode="w")
+ for i in range(len(tb)):
+ f.write("%d %d " % (tb[i].count, tb[i].size))
+ f.write(",".join([str(tb[i].links[j]) for j in range(len(tb))]) + "\n")
+ f.close()
+
+dump_heap.unwrap_spec = [ObjSpace, str]
More information about the Pypy-commit
mailing list