Realm

vk::mem · Functions · T1

2 public declarations with native signatures and source-owned contracts.

FnRustExperimental

Fnvk::mem::trim

Contract

Release surplus empty, unmapped cached blocks, preserving each pool minimum.

Free/method forms share this operation. Pools remain live and can grow again. No native budget query, host allocation, submit/wait or relocation is performed. Native resource uses must already have ended through the existing unsafe free/ destroy contract before a block can become empty. Dropping anything never trims. Includes explicit-size default blocks retained by an abandoned Extensive context.

Errors

Returns Closed after allocator close.

Fnvk::mem::trim_with_budget

pub unsafe fn trim_with_budget( allocator: &mut Allocator<'_>, instance: &Instance, physical: PhysicalDevice, ) -> Result<TrimStats, AllocError>
Query an explicit budget snapshot, then trim surplus empty blocks on pressured heaps.

Contract

Query an explicit budget snapshot, then trim surplus empty blocks on pressured heaps.

Pressure means usage >= budget or native bytes >= the local heap ceiling. Without enabled EXT_memory_budget the snapshot is explicitly local. The selection subtracts released native bytes from that one snapshot, stopping once projected pressure ends or no eligible block remains. External usage may change immediately; this does not promise allocation success or budget compliance. No snapshot is cached and no live resource is evicted or moved.

Errors

Returns closed/context/capability/native query errors before freeing memory.

Safety

Instance/physical device must be the live parent used to create this allocator’s device.