소스 검색

log number of garbage cycles even if we've previously printed the full info on those cycles

Darren Ranalli 17 년 전
부모
커밋
fcfd9f8e20
1개의 변경된 파일11개의 추가작업 그리고 8개의 파일을 삭제
  1. 11 8
      direct/src/showbase/GarbageReport.py

+ 11 - 8
direct/src/showbase/GarbageReport.py

@@ -514,8 +514,9 @@ class GarbageReport(Job):
 class GarbageLogger(GarbageReport):
     """If you just want to log the current garbage to the log file, make
     one of these. It automatically destroys itself after logging"""
-    # variable for checkForGarbageLeaks
+    # for checkForGarbageLeaks
     LastNumGarbage = 0
+    LastNumCycles = 0
     def __init__(self, name, *args, **kArgs):
         kArgs['log'] = True
         kArgs['autoDestroy'] = True
@@ -524,18 +525,20 @@ class GarbageLogger(GarbageReport):
 def checkForGarbageLeaks():
     gc.collect()
     numGarbage = len(gc.garbage)
-    if ((numGarbage != GarbageLogger.LastNumGarbage) and
-        (not configIsToday('disable-garbage-logging'))):
-        GarbageLogger.LastNumGarbage = numGarbage
-        print
-        gr = GarbageLogger('found garbage', threaded=False, collect=False)
-        print
+    if (numGarbage > 0 and (not configIsToday('disable-garbage-logging'))):
+        if (numGarbage != GarbageLogger.LastNumGarbage):
+            print
+            gr = GarbageLogger('found garbage', threaded=False, collect=False)
+            print
+            GarbageLogger.LastNumGarbage = numGarbage
+            GarbageLogger.LastNumCycles = gr.getNumCycles()
         notify = directNotify.newCategory("GarbageDetect")
         if config.GetBool('allow-garbage-cycles', 1):
             func = notify.warning
         else:
             func = notify.error
-        func('%s garbage cycles found, see info above' % gr.getNumCycles())
+        func('%s garbage cycles found, see info above' %
+             GarbageLogger.LastNumCycles)
     return numGarbage
 
 def b_checkForGarbageLeaks(wantReply=False):