Browse Source

don't re-print garbage info if no new garbage

Darren Ranalli 17 years ago
parent
commit
90eb2bf52e
1 changed files with 5 additions and 1 deletions
  1. 5 1
      direct/src/showbase/GarbageReport.py

+ 5 - 1
direct/src/showbase/GarbageReport.py

@@ -509,6 +509,8 @@ class GarbageReport(Job):
 class GarbageLogger(GarbageReport):
 class GarbageLogger(GarbageReport):
     """If you just want to log the current garbage to the log file, make
     """If you just want to log the current garbage to the log file, make
     one of these. It automatically destroys itself after logging"""
     one of these. It automatically destroys itself after logging"""
+    # variable for checkForGarbageLeaks
+    LastNumGarbage = 0
     def __init__(self, name, *args, **kArgs):
     def __init__(self, name, *args, **kArgs):
         kArgs['log'] = True
         kArgs['log'] = True
         kArgs['autoDestroy'] = True
         kArgs['autoDestroy'] = True
@@ -517,7 +519,9 @@ class GarbageLogger(GarbageReport):
 def checkForGarbageLeaks():
 def checkForGarbageLeaks():
     gc.collect()
     gc.collect()
     numGarbage = len(gc.garbage)
     numGarbage = len(gc.garbage)
-    if numGarbage and not configIsToday('disable-garbage-logging'):
+    if ((numGarbage != GarbageLogger.LastNumGarbage) and
+        (not configIsToday('disable-garbage-logging'))):
+        GarbageLogger.LastNumGarbage = numGarbage
         print
         print
         gr = GarbageLogger('found garbage', threaded=False)
         gr = GarbageLogger('found garbage', threaded=False)
         print
         print