From 81ac975fe2bdcd95de1faed9a318f3867aa95059 Mon Sep 17 00:00:00 2001 From: bescoto Date: Sat, 24 Dec 2005 20:02:05 +0000 Subject: Reduce hardlink memory usage git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@719 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/testing/commontest.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'rdiff-backup/testing') diff --git a/rdiff-backup/testing/commontest.py b/rdiff-backup/testing/commontest.py index 04cdb93..e9b272e 100644 --- a/rdiff-backup/testing/commontest.py +++ b/rdiff-backup/testing/commontest.py @@ -386,4 +386,19 @@ def raise_interpreter(use_locals = None): else: local_dict = globals() code.InteractiveConsole(local_dict).interact() - +def getrefs(i, depth): + """Get the i'th object in memory, return objects that reference it""" + import sys, gc, types + o = sys.getobjects(i)[-1] + for d in range(depth): + for ref in gc.get_referrers(o): + if type(ref) in (types.ListType, types.DictType, + types.InstanceType): + if type(ref) is types.DictType and ref.has_key('copyright'): + continue + o = ref + break + else: + print "Max depth ", d + return o + return o -- cgit v1.2.1