public class NativeAllocationTracer extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
NativeAllocationTracer.Location
Represents a specific location in source code identified by class, method, file, and line number.
|
static class |
NativeAllocationTracer.Site
Contains allocation statistics for a specific source code location.
|
| Modifier and Type | Field and Description |
|---|---|
private static Logger |
logger |
private static WeakHashMap<Pointer,NativeAllocationTracer.Location> |
pointerLocations
Maps for remember where each Pointer object was created
|
private static WeakHashMap<PhantomReference<Pointer>,NativeAllocationTracer.Location> |
pointerReferenceLocations
Maps phantom references to allocation sites for GC-time tracking
|
private static HashMap<NativeAllocationTracer.Location,NativeAllocationTracer.Site> |
sites
Maps source code locations to their allocation statistics
|
| Constructor and Description |
|---|
NativeAllocationTracer() |
| Modifier and Type | Method and Description |
|---|---|
private static NativeAllocationTracer.Location |
captureCreationLocation(Class<?> createdClass)
Captures the location in the source code where an instance creation occurs.
|
static Collection<NativeAllocationTracer.Site> |
getSites()
Retrieves a collection of all currently tracked allocation sites.
|
private static void |
markPointer(Pointer pointer)
Associates a Pointer with its creation location for future tracking
|
private static void |
markReference(PhantomReference<Pointer> pointerReference,
Pointer pointer)
Associates a Pointer Reference with its allocation location for tracking during GC.
|
private static void |
recordAllocation(PhantomReference<Pointer> pointerReference,
long size)
Records when native memory is allocated, updating total and live statistics.
|
private static void |
recordCollection(PhantomReference<Pointer> pointerReference,
long size)
Records when native memory is garbage collected, updating collection statistics.
|
private static void |
recordDeallocation(PhantomReference<Pointer> pointerReference,
long size)
Records when native memory is manually deallocated, updating live statistics.
|
private static final Logger logger
private static final HashMap<NativeAllocationTracer.Location,NativeAllocationTracer.Site> sites
private static final WeakHashMap<Pointer,NativeAllocationTracer.Location> pointerLocations
private static final WeakHashMap<PhantomReference<Pointer>,NativeAllocationTracer.Location> pointerReferenceLocations
public static Collection<NativeAllocationTracer.Site> getSites()
Site objects representing the allocation statisticsprivate static void markPointer(Pointer pointer)
pointer - the Pointer object to be marked and trackedprivate static void markReference(PhantomReference<Pointer> pointerReference, Pointer pointer)
pointerReference - the phantom reference to be marked and trackedpointer - the Pointer object associated with the phantom referenceprivate static void recordAllocation(PhantomReference<Pointer> pointerReference, long size)
pointerReference - the phantom reference associated with the allocationsize - the number of bytes allocatedprivate static void recordDeallocation(PhantomReference<Pointer> pointerReference, long size)
pointerReference - the phantom reference associated with the deallocationsize - the number of bytes deallocatedprivate static void recordCollection(PhantomReference<Pointer> pointerReference, long size)
pointerReference - the phantom reference associated with the garbage collected memorysize - the number of bytes garbage collectedprivate static NativeAllocationTracer.Location captureCreationLocation(Class<?> createdClass)
createdClass - the class of the object being createdCopyright © 2026. All rights reserved.