Module memory

Source
Expand description

Provides a public interface for querying engine-wide memory allocation statistics.

This module defines a set of global atomic counters for detailed memory tracking. It forms a “contract” where a registered global allocator is responsible for incrementing these counters, and any part of the engine can read them in a thread-safe manner to monitor memory usage.

The primary use case is for the khora-telemetry crate to collect these stats and feed them into the Dynamic Context Core (DCC) for adaptive decision-making.

Structs§

ExtendedMemoryStats
A snapshot of comprehensive memory allocation statistics, including derived metrics.

Statics§

BYTES_ALLOCATED_LIFETIME
Tracks the cumulative total of bytes ever allocated over the application’s lifetime.
BYTES_DEALLOCATED_LIFETIME
Tracks the cumulative total of bytes ever deallocated over the application’s lifetime.
CURRENTLY_ALLOCATED_BYTES
Tracks the total number of bytes currently allocated by the registered global allocator.
LARGE_ALLOCATIONS
Tracks the number of “large” allocations (e.g., >= 1MB).
LARGE_ALLOCATION_BYTES
Tracks the cumulative total of bytes from “large” allocations.
PEAK_ALLOCATED_BYTES
Tracks the peak number of bytes ever allocated simultaneously during the application’s lifetime.
SMALL_ALLOCATIONS
Tracks the number of “small” allocations (e.g., < 1KB).
SMALL_ALLOCATION_BYTES
Tracks the cumulative total of bytes from “small” allocations.
TOTAL_ALLOCATIONS
Tracks the total number of allocation calls made.
TOTAL_DEALLOCATIONS
Tracks the total number of deallocation calls made.
TOTAL_REALLOCATIONS
Tracks the total number of reallocation calls made.

Functions§

get_currently_allocated_bytes
Gets the total number of bytes currently allocated by the global allocator.
get_extended_memory_stats
Takes a snapshot of all global memory counters and returns them in a structured format.