diagnosticMalloc top-level constant
DiagnosticMallocAllocator
const diagnosticMalloc
A non-zero-initializing allocator that always retains leak-tracking capability.
Unlike adaptiveMalloc, this allocator is never optimized away in release builds. It records allocation metadata with the leak tracker in every build mode whenever leak tracking is enabled.
Platform behavior:
- Windows: uses
CoTaskMemAlloc/CoTaskMemFree - POSIX: uses
malloc/free
This allocator is intended for explicit diagnostic scenarios — for example, when investigating memory issues that only reproduce in release builds. Avoid using it as a general-purpose allocator in performance-sensitive code.
Implementation
const diagnosticMalloc = DiagnosticMallocAllocator._();