+dict_proxy = type(OSHeapSize.__dict__)
""" Basic heap collector that implements all methods for walking objects,
+ for obj in [self, self.seen, self.counted, self.deferred_dicts, self.typecategory]:
def _count_obj(self, obj):
""" Count the size of the given object including its dictionary"""
# skip if we've already seen this object
- if obj_id in self.
+ if obj_id in self.:
- # if object is a dict, do it later, because XXX
+ # if object is a dict, do it later, because it could be an object's
if isinstance(obj, dict) and self.deferred_dicts is not None:
seen.add(obj_id) # mark object as seen
+ self..add(obj_id) # mark object as seen
# remeber all types we have seen
# add object to total memory usage (for that type)
- # if object has a dict that we haven't me
saured yet, do it now
+ # if object has a dict that we haven't meaured yet, do it now
- if d is None or id(d) in self.seen:
+ if isinstance(d, dict_proxy):
+ if d is None or id(d) in self.counted:
self.count_dict(obj, d, key)
""" Follow all referents of the given object and add them to the
total memory size of its type category """
- #if id(obj) in self.seen or obj in self.deferred_dicts:
+ if obj_id in self.seen:
referents = gc.get_referents(obj)
""" Count all dictionaries that were skipped in _count_obj """