com.neeve.util
Class UtlReferenceTracker

java.lang.Object
  extended by com.neeve.util.UtlReferenceTracker

public class UtlReferenceTracker
extends Object

Tracks references for a reference counted object.

Reference tracking is enabled as follows:

Reference tracking is very expensive and should only be enabled when debugging reference counting issues.

This class IS NOT intended to be used by end users.


Nested Class Summary
static interface UtlReferenceTracker.HasReferenceTracker
          Marks an object as having a reference tracker.
 
Field Summary
static boolean ENABLED
          True if reference tracking is globally enabled in the System.
static boolean TYPE_TRACKING_ENABLED
          True if reference tracking is enabled for at least one type in the System.
 
Constructor Summary
UtlReferenceTracker(Object item)
           
 
Method Summary
 void dump()
           
 void dump(StringBuilder sb)
           
static boolean enabled(Class<?> type)
          Tests if reference tracking is enabled for the given type.
 void onAcquire(int newCount)
           
 void onDispose(int newCount)
           
 void onInit(int initCount)
           
 void onUndispose(int oldCount, int initCount)
           
 void setAssociatedTracker(UtlReferenceTracker associatedTracker)
          Sets a tracker associated with this tracker, for example a parent or child tracker.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENABLED

public static final boolean ENABLED
True if reference tracking is globally enabled in the System.


TYPE_TRACKING_ENABLED

public static final boolean TYPE_TRACKING_ENABLED
True if reference tracking is enabled for at least one type in the System. This will always be true if ENABLED is set to true.

Constructor Detail

UtlReferenceTracker

public UtlReferenceTracker(Object item)
Method Detail

onUndispose

public final void onUndispose(int oldCount,
                              int initCount)

onInit

public final void onInit(int initCount)

onAcquire

public final void onAcquire(int newCount)

onDispose

public final void onDispose(int newCount)

dump

public final void dump()

dump

public final void dump(StringBuilder sb)

setAssociatedTracker

public void setAssociatedTracker(UtlReferenceTracker associatedTracker)
Sets a tracker associated with this tracker, for example a parent or child tracker. When this tracker's history is dumped the associated history will be included.

NOTE: Cycles of associations are not currently supported and will result in an infinite dump loop.

Parameters:
associatedTracker - A tracker associated with this one.

enabled

public static boolean enabled(Class<?> type)
Tests if reference tracking is enabled for the given type.

Parameters:
type - The type to check against for reference tracking.
Returns:
True if enabled.


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.