def _genObjectStatus():
"""
Generate a report with information about objects allocated, numbers of
references to each object and other information that can be used to
track down memory (object) leaks in the server.
Returns: Object report (string).
"""
T = TRACE()
rep = "NG/AMS SERVER OBJECT STATUS REPORT\n\n"
import gc
gc.set_debug(gc.DEBUG_COLLECTABLE | gc.DEBUG_UNCOLLECTABLE |
gc.DEBUG_INSTANCES | gc.DEBUG_OBJECTS)
rep += "=Garbage Collector Status:\n\n"
rep += "Enabled: %d\n" % gc.isenabled()
rep += "Unreachable objects: %d\n" % gc.collect()
rep += "Threshold: %s\n" % str(gc.get_threshold())
#rep += "Objects:\n"
#rep += str(gc.get_objects()) + "\n"
rep += "Garbage:\n"
rep += str(gc.garbage) + "\n\n"
# Dump refence count status of all objects allocated into file specified.
rep += "=Object Reference Counts:\n\n"
for objInfo in _genRefCountRep():
rep += "%-4d %s\n" % (objInfo[0], objInfo[1])
rep += "\n=EOF"
return rep
评论列表
文章目录