pub struct TurboMalloc;Expand description
Turbo’s preferred global allocator. This is a new type instead of a type alias because you can’t use type aliases to instantiate unit types (E0423).
Implementations§
Source§impl TurboMalloc
impl TurboMalloc
Sourcepub fn memory_usage() -> usize
pub fn memory_usage() -> usize
Returns the current amount of live memory (bytes allocated minus freed) tracked across all threads.
For efficiency reasons every thread only synchronizes with this counter after ~100K bytes of allocations or deallocations. So this could be off by as much as 100K*number of thread in either direction.
pub fn thread_stop()
pub fn thread_park()
Sourcepub fn collect(force: bool)
pub fn collect(force: bool)
When using mimalloc triggers some cleanup
force=false: process threadlocal free lists and other threadlocal deferred work
only operates on thread local data and should be fast
force=true: do all the work of process=false and then process global shared structures and
return memory to the OS if possible, this is much slower and should only be done rarely.
pub fn allocation_counters() -> AllocationCounters
pub fn reset_allocation_counters(start: AllocationCounters)
Sourcepub fn memory_pressure() -> Option<u8>
pub fn memory_pressure() -> Option<u8>
Returns a memory pressure value in the range 0..=100, or None when
the current platform does not expose a memory pressure signal or a
query for it failed.
0 means no memory pressure, 100 means maximum pressure.
- On Linux this is derived from
/proc/pressure/memory(thesomeavg10stall percentage), falling back to(MemTotal - MemAvailable) / MemTotalfrom/proc/meminfowhen PSI is not available (older kernels, noCONFIG_PSI, or containers without access). - On macOS this is derived from the
kern.memorystatus_levelsysctl (100 - free_memory_percentage). - On Windows this is
MEMORYSTATUSEX::dwMemoryLoad(percentage of physical memory in use). - On other platforms this returns
None.
Trait Implementations§
Source§impl GlobalAlloc for TurboMalloc
impl GlobalAlloc for TurboMalloc
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
layout. Read more