def assert_no_dangling_Cclasses(doassert=None): global CheckForDanglingClasses global WorstDanglingCount sys._clear_type_cache() if doassert is None: doassert = AssertOnDanglingClasses CMAinit.uninit() gc.collect() # For good measure... count = proj_class_live_object_count() #print >>sys.stderr, "CHECKING FOR DANGLING CLASSES (%d)..." % count # Avoid cluttering the output up with redundant messages... if count > WorstDanglingCount and CheckForDanglingClasses: WorstDanglingCount = count if doassert: print >> sys.stderr, 'STARTING OBJECT DUMP' print 'stdout STARTING OBJECT DUMP' dump_c_objects() print >> sys.stderr, 'OBJECT DUMP COMPLETE' print 'stdout OBJECT DUMP COMPLETE' raise AssertionError("Dangling C-class objects - %d still around" % count) else: print >> sys.stderr, ( "*****ERROR: Dangling C-class objects - %d still around" % count)
def _check_memory_usage(): 'Check to see if we have too many objects outstanding right now' gccount = gc.get_count() gctotal = 0 for elem in gccount: gctotal += elem CMAdb.log.info('Total allocated Objects: %s. gc levels: %s' % (gctotal, str(gccount))) cobjcount = proj_class_live_object_count() CMAdb.log.info('Total/max allocated C-Objects: %s/%s' % (cobjcount, proj_class_max_object_count())) if gctotal < 20 and cobjcount > 5000: dump_c_objects() if CMAdb.debug: # Another very expensive set of debug-only calls assimcount = 0 for obj in gc.get_objects(): if isinstance(obj, (pyAssimObj)): assimcount += 1 CMAdb.log.info('Total allocated C-Objects: %s' % assimcount)
def assert_no_dangling_Cclasses(doassert=None): global CheckForDanglingClasses global WorstDanglingCount if doassert is None: doassert = AssertOnDanglingClasses CMAinit.uninit() gc.collect() # For good measure... count = proj_class_live_object_count() # print >>sys.stderr, "CHECKING FOR DANGLING CLASSES (%d)..." % count # Avoid cluttering the output up with redundant messages... if count > WorstDanglingCount and CheckForDanglingClasses: WorstDanglingCount = count if doassert: print >> sys.stderr, "STARTING OBJECT DUMP" print "stdout STARTING OBJECT DUMP" dump_c_objects() print >> sys.stderr, "OBJECT DUMP COMPLETE" print "stdout OBJECT DUMP COMPLETE" raise AssertionError("Dangling C-class objects - %d still around" % count) else: print >> sys.stderr, ("*****ERROR: Dangling C-class objects - %d still around" % count)