com.google.monitoring.runtime.instrumentation
Class AllocationRecorder

java.lang.Object
  extended by com.google.monitoring.runtime.instrumentation.AllocationRecorder

public class AllocationRecorder
extends Object

The logic for recording allocations, called from bytecode rewritten by AllocationInstrumenter.

Author:
jeremymanson@google.com (Jeremy Manson), fischman@google.com (Ami Fischman)

Field Summary
static ThreadLocal<Boolean> recordingAllocation
           
 
Constructor Summary
AllocationRecorder()
           
 
Method Summary
static void addSampler(Sampler sampler)
          Adds a Sampler that will get run every time an allocation is performed from Java code.
static void recordAllocation(Class<?> cls, Object newObj)
           
static void recordAllocation(int count, String desc, Object newObj)
          Records the allocation.
static void recordAllocationForceForTest(int count, String desc, Object newObj)
          Helper method to force recording; for unit tests only.
static void recordAllocationForceForTestReal(int count, String desc, Object newObj, int recurse)
           
static void removeSampler(Sampler sampler)
          Removes the given Sampler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

recordingAllocation

public static final ThreadLocal<Boolean> recordingAllocation
Constructor Detail

AllocationRecorder

public AllocationRecorder()
Method Detail

addSampler

public static void addSampler(Sampler sampler)
Adds a Sampler that will get run every time an allocation is performed from Java code. Use this with extreme judiciousness!

Parameters:
sampler - The sampler to add.

removeSampler

public static void removeSampler(Sampler sampler)
Removes the given Sampler.

Parameters:
sampler - The sampler to remove.

recordAllocation

public static void recordAllocation(Class<?> cls,
                                    Object newObj)

recordAllocation

public static void recordAllocation(int count,
                                    String desc,
                                    Object newObj)
Records the allocation. This method is invoked on every allocation performed by the system.

Parameters:
count - the count of how many instances are being allocated, if an array is being allocated. If an array is not being allocated, then this value will be -1.
desc - the descriptor of the class/primitive type being allocated.
newObj - the new Object whose allocation is being recorded.

recordAllocationForceForTest

public static void recordAllocationForceForTest(int count,
                                                String desc,
                                                Object newObj)
Helper method to force recording; for unit tests only.


recordAllocationForceForTestReal

public static void recordAllocationForceForTestReal(int count,
                                                    String desc,
                                                    Object newObj,
                                                    int recurse)


Copyright © 2015. All Rights Reserved.