pub struct SaaTrackingAllocator<A = System> { /* private fields */ }
Expand description
A wrapper around a GlobalAlloc
implementation (like std::alloc::System
)
that intercepts allocation calls to update the global memory counters defined
in khora_core::memory
.
This allocator is the key to enabling the SAA’s memory monitoring. By registering
it as the #[global_allocator]
, all heap allocations made by the application
will be tracked, providing essential telemetry to the Dynamic Context Core (DCC).
§Type Parameters
A
: The underlying allocator that will perform the actual memory allocation. Defaults toSystem
, the standard Rust allocator.
§Usage
use khora_data::allocators::SaaTrackingAllocator;
#[global_allocator]
static GLOBAL: SaaTrackingAllocator = SaaTrackingAllocator::new(std::alloc::System);
Implementations§
Source§impl<A> SaaTrackingAllocator<A>
impl<A> SaaTrackingAllocator<A>
Trait Implementations§
Source§impl<A: Clone> Clone for SaaTrackingAllocator<A>
impl<A: Clone> Clone for SaaTrackingAllocator<A>
Source§fn clone(&self) -> SaaTrackingAllocator<A>
fn clone(&self) -> SaaTrackingAllocator<A>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<A: Debug> Debug for SaaTrackingAllocator<A>
impl<A: Debug> Debug for SaaTrackingAllocator<A>
Source§impl<A: Default> Default for SaaTrackingAllocator<A>
impl<A: Default> Default for SaaTrackingAllocator<A>
Source§fn default() -> SaaTrackingAllocator<A>
fn default() -> SaaTrackingAllocator<A>
Source§impl<A: GlobalAlloc> GlobalAlloc for SaaTrackingAllocator<A>
impl<A: GlobalAlloc> GlobalAlloc for SaaTrackingAllocator<A>
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
Allocates memory and updates tracking counters.
§Safety
This function is unsafe because it is part of the GlobalAlloc
trait.
The caller must ensure that layout
has a non-zero size.
Source§unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)
Deallocates memory and updates tracking counters.
§Safety
This function is unsafe because it is part of the GlobalAlloc
trait.
The caller must ensure that ptr
was allocated by this allocator with the same layout
.