diff options
author | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2005-12-24 20:02:05 +0000 |
---|---|---|
committer | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2005-12-24 20:02:05 +0000 |
commit | 81ac975fe2bdcd95de1faed9a318f3867aa95059 (patch) | |
tree | a2498875818e50c257c33b4005a9ee046825a80c /rdiff-backup/testing | |
parent | 5c7697c75d65acf2cb319dabcb573e3c22ccac56 (diff) | |
download | rdiff-backup-81ac975fe2bdcd95de1faed9a318f3867aa95059.tar.gz |
Reduce hardlink memory usage
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@719 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing')
-rw-r--r-- | rdiff-backup/testing/commontest.py | 17 |
1 files changed, 16 insertions, 1 deletions
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 |