Loading...
Searching...
No Matches
Public Member Functions | List of all members
cppgc::AllocationSampler Class Referenceabstract

#include <platform.h>

Public Member Functions

virtual ~AllocationSampler ()=default
 
virtual size_t GetSampleInterval () const
 
virtual bool OnAllocated (void *address, size_t size)=0
 
virtual void OnFreed (void *address)=0
 
virtual bool OnMove (void *from, void *to, size_t size)=0
 

Detailed Description

Interface for observing object-level allocations and deallocations in cppgc.

Implementations of these methods must not allocate on the managed heap(s) (C++ or JS) or otherwise call back into V8.

Constructor & Destructor Documentation

◆ ~AllocationSampler()

virtual cppgc::AllocationSampler::~AllocationSampler ( )
virtualdefault

Member Function Documentation

◆ GetSampleInterval()

virtual size_t cppgc::AllocationSampler::GetSampleInterval ( ) const
inlinevirtual

Returns the desired sampling interval in bytes. Embedders must return a non-zero value to activate periodic sampling. Must not allocate on the managed heap(s) (C++ or JS) or otherwise call back into V8.

Returns
the configured mean sampling interval in bytes, or 0 if unset.

◆ OnAllocated()

virtual bool cppgc::AllocationSampler::OnAllocated ( void *  address,
size_t  size 
)
pure virtual

Invoked when an object or memory chunk is allocated. Must not allocate on the managed heap(s) (C++ or JS) or otherwise call back into V8.

Parameters
addressPointer to the allocated memory.
sizeTotal size of the allocation in bytes (including object header).
Returns
true if this allocation was selected as a sample and should be tracked for deallocation, false otherwise.

◆ OnFreed()

virtual void cppgc::AllocationSampler::OnFreed ( void *  address)
pure virtual

Invoked when an allocated object or memory chunk is freed/reclaimed. Must not allocate on the managed heap(s) (C++ or JS) or otherwise call back into V8.

Parameters
addressPointer to the allocated memory.

◆ OnMove()

virtual bool cppgc::AllocationSampler::OnMove ( void *  from,
void *  to,
size_t  size 
)
pure virtual

Invoked when a sampled object is moved to a new location. Must not allocate on the managed heap(s) (C++ or JS) or otherwise call back into V8.

Parameters
fromPointer to the old memory location.
toPointer to the new memory location.
sizeTotal size of the allocation in bytes (including object header).
Returns
true if the moved allocation was selected as a sample and should be tracked for deallocation, false otherwise.

The documentation for this class was generated from the following file: