Class AllocationRecorder
java.lang.Object
com.google.monitoring.runtime.instrumentation.AllocationRecorder
The logic for recording allocations, called from bytecode rewritten by
AllocationInstrumenter.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddSampler(Sampler sampler) Adds aSamplerthat will get run every time an allocation is performed from Java code.static voidrecordAllocation(int count, String desc, Object newObj) Records the allocation.static voidrecordAllocation(Class<?> cls, Object newObj) static voidrecordAllocationForceForTest(int count, String desc, Object newObj) Helper method to force recording; for unit tests only.static voidrecordAllocationForceForTestReal(int count, String desc, Object newObj, int recurse) Helper method to force recording; for unit tests only.static voidremoveSampler(Sampler sampler) Removes the givenSampler.
-
Constructor Details
-
AllocationRecorder
public AllocationRecorder()
-
-
Method Details
-
addSampler
Adds aSamplerthat will get run every time an allocation is performed from Java code. Use this with extreme judiciousness!- Parameters:
sampler- The sampler to add.
-
removeSampler
Removes the givenSampler.- Parameters:
sampler- The sampler to remove.
-
recordAllocation
-
recordAllocation
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 newObjectwhose allocation is being recorded.
-
recordAllocationForceForTest
Helper method to force recording; for unit tests only.- Parameters:
count- the number of objects being allocated.desc- the descriptor of the class of the object being allocated.newObj- the object being allocated.
-
recordAllocationForceForTestReal
public static void recordAllocationForceForTestReal(int count, String desc, Object newObj, int recurse) Helper method to force recording; for unit tests only.- Parameters:
count- the number of objects being allocated.desc- the descriptor of the class of the object being allocated.newObj- the object being allocated.recurse- A recursion count.
-