#@+leo-ver=4
#@+node:@file trace_gc.py
"""Trace changes to objects at idle time"""

from leoPlugins import *
from leoGlobals import *

import leoGlobals
leoGlobals.debugGC = true # Force debugging on.

def printIdleRefs(tag,keywords):
	printGcRefs(verbose=false)
	
gcCount = 0

def printIdleGC(tag,keywords):
	
	# Calling printGc is too expensive to do on every idle call.
	if tag == "idle":
		global gcCount ; gcCount += 1
		if (gcCount % 20) == 0:
			printGc(tag,onlyPrintChanges=true)
	else:
		printGc(tag,onlyPrintChanges=false)

# Register the handlers...
if 1: # Very effective.
	registerHandler("idle", printIdleGC)
else: # Very precise.
	registerHandler("all", printIdleGC)
if 0: # Another idea.
	registerHandler("command2", printIdleRefs)

__version__ = "1.3"
plugin_signon(__name__)
#@nonl
#@-node:@file trace_gc.py
#@-leo
