vk::mem::Allocator
Borrows one device; native memory is released only by explicit operations.
Contract
Borrows one device; native memory is released only by explicit operations.
Each allocation has an allocator identity and generation. Dropping either the allocator or a token can leak native objects; it never calls Vulkan.
Methods and associated items
set_external_memory_types
Copy an external export profile before any pool/native acquisition.
Errors
Same validation errors as mem::set_external_memory_types.
Safety
All future resources and native allocations must meet the configured export valid usage.
external_memory_types
get_memory_fd
Export one caller-owned descriptor for the complete backing memory.
Errors
Same checked identity/admission and native failures as mem::get_memory_fd.
Safety
Caller meets sharing/synchronization requirements and closes the returned descriptor.
create_pool_with_chain
Create a custom pool retaining a borrowed chain for future native allocations.
Errors
Same checked policy/chain/native errors as mem::create_pool_with_chain.
Safety
Retain the complete immutable chain for the device borrow; every block must meet native valid usage.
set_debug_memory_settings
Configure opt-in guard/fill instrumentation before acquiring memory/pools.
check_corruption
Explicitly inspect enabled coherent pooled debug guards after completion.
Safety
Same all-selected-region access contract as mem::check_corruption.
check_pool_corruption
Inspect one custom pool’s enabled coherent debug guards.
Safety
Same pool completion/access contract as mem::check_pool_corruption.
begin_defragmentation
Begin an explicitly resolved relocation pass over eligible ordinary TLSF allocations.
Safety
Same native resource and explicit completion/commit contract as mem::begin_defragmentation.
begin_defragmentation_with_break
Plan with a borrowed stop predicate; interrupted proposals still need resolution.
Safety
Same source/alias/pointer/completion contract as mem::begin_defragmentation_with_break.
set_allocation_pinned
Prevent or admit an allocation in future explicit relocation passes.
detailed_pool_statistics
Calculate detailed checked custom-pool native/live/free-span diagnostics.
write_statistics_json
Stream explicit local JSON diagnostics; detailed mode includes allocations/free spans.
detailed_statistics
Calculate explicit per-type/per-heap byte, count, free-span and extent diagnostics.
allocate_many
Allocate a transactional batch of ordinary raw requirement pages.
Safety
Same requirements/feature/release contract as mem::allocate_many.
free_many
Release a fully prevalidated batch after explicit native resource destruction.
Safety
Same completion/ownership contract as mem::free_many.
flush_many
Flush a batch of allocation-relative mapped ranges in one native call.
Safety
Same host/GPU visibility contract as mem::flush_many.
invalidate_many
Invalidate a batch after completion of device writes.
Safety
Same host/GPU visibility contract as mem::invalidate_many.
copy_to_allocation
Copy host bytes, flush and balance the helper’s explicit map hold.
Safety
Same pointer/access/layout contract as mem::copy_to_allocation.
copy_from_allocation
Invalidate and copy bytes to exclusive writable host storage.
Safety
Same completion/initialization contract as mem::copy_from_allocation.
allocation_name
Borrow an allocation’s checked diagnostic name.
set_allocation_name
Replace a copied name; None clears it.
set_allocation_user_data
Set opaque consumer metadata, with no ownership or dereference.
pool_name
Borrow a checked pool’s diagnostic name.
set_pool_name
Replace a copied pool name; None clears it.
allocation_callbacks
Borrow this allocator’s retained native callbacks for matching explicit resource cleanup.
create_aliasing_buffer
Create and bind a caller-owned buffer alias without allocating memory.
Safety
Same alias/barrier/feature/lifetime contract as mem::create_aliasing_buffer.
create_aliasing_image
Create and bind a caller-owned image alias without allocating memory.
Safety
Same native alias/layout/barrier contract as mem::create_aliasing_image.
set_device_memory_callbacks
Register borrowed informative callbacks before acquiring native memory/pools.
Errors
Rejects closed allocators or any existing native allocation/pool domain.
Safety
User data must remain live for the callback registration. Functions must not unwind, reenter this allocator or violate their host thread/synchronization contract.
info
Query retained native identity metadata, with explicit None for unknown manual parents.
memory_properties
Borrow this allocator’s validated physical memory properties.
physical_device_properties
Borrow queried physical-device properties if the construction route captured them.
memory_type_properties
Query one validated native memory type’s property flags.
find_memory_type
Select from explicit requirements bits without allocating native storage.
Errors
Same checked policy/type/identity errors as mem::find_memory_type.
find_memory_type_for_buffer_info
Select using ordinary buffer creation usage and native requirements.
Safety
Same native valid-usage/lifetime contract as mem::find_memory_type_for_buffer_info.
find_memory_type_for_image_info
Select using ordinary image creation usage and native requirements.
Safety
Same native valid-usage/lifetime contract as mem::find_memory_type_for_image_info.
allocate_with_options
Allocate raw separate/pooled storage using the canonical managed placement path.
Safety
Same ordinary requirements, completion and release contract as mem::allocate_with_options.
allocate_dedicated
Allocate separate native storage with a borrowed chain.
Errors
Same checked/native/chain errors as mem::allocate_dedicated.
Safety
Same requirements, chain, import ownership and completion obligations.
create_dedicated_buffer
Create a separately allocated/bound buffer with an optional native chain.
Errors
Same checked/native/rollback errors as mem::create_dedicated_buffer.
Safety
Same complete resource/allocation external-memory and completion obligations.
create_dedicated_image
Create a separately allocated/bound image with an optional native chain.
Errors
Same checked/native/rollback errors as mem::create_dedicated_image.
Safety
Same complete resource/allocation external-memory and completion obligations.
bind_buffer_memory2
Bind an ordinary buffer with explicit local offset and borrowed native bind chain.
Safety
Same native chain/resource contract as mem::bind_buffer_memory2.
bind_image_memory2
Bind an ordinary image with explicit local offset and borrowed native bind chain.
Safety
Same native chain/resource contract as mem::bind_image_memory2.
allocate_for_buffer
Allocate for an existing unbound ordinary buffer; retains caller ownership on error.
Safety
Same resource/feature/callback/lifetime contract as mem::allocate_for_buffer.
allocate_for_image
Allocate for an existing ordinary image using conservative unknown-tiling placement.
Safety
Same resource/feature/callback/lifetime contract as mem::allocate_for_image.
bind_buffer_memory
Bind a matching buffer/allocation pair; failure retains both for explicit retry.
Safety
Same native unbound-resource and synchronization contract as mem::bind_buffer_memory.
bind_image_memory
Bind a matching ordinary image/allocation pair; no implicit destruction on failure.
Safety
Same native image/lifetime/synchronization contract as mem::bind_image_memory.
set_heap_limit
Set a local native-byte ceiling. Existing allocations are never evicted.
budget_snapshot
Heap-size/local-accounting estimate, without querying the driver.
trim
Release empty, unmapped cached blocks above their pool minimums. No driver budget query, allocation, synchronization or live-object movement.
Errors
Returns Closed after allocator close.
trim_with_budget
Query budget pressure and release eligible empty blocks on pressured heaps. Minimum blocks and all live/mapped blocks remain owned by their pools.
Errors
Returns closed/context/capability/native query errors before freeing memory.
Safety
Supply the live instance and physical device used to create this allocator’s device.
query_budget
Query enabled EXT_memory_budget; otherwise return an explicitly local estimate.
Safety
Instance/physical device must be the live parent used to create this allocator’s device.
refresh_budget
Explicitly refresh allocator-owned native/local budgets.
refresh_budget_with_context
Capture a native query context under a retained parent-lifetime contract.
Safety
Same identity/lifetime contract as mem::refresh_budget_with_context.
heap_budgets
Get owned cached/periodically refreshed heap budgets with local native-byte deltas.
set_current_frame_index
Mark an explicit budget frame boundary; no completion or retirement is implied.
current_frame_index
create_pool
Create a fixed-type pool with the selected placement algorithm and minimum blocks.
Errors
Rejects invalid policy/types/limits and preserves metadata/native failures.
Safety
The device/physical metadata and native allocation limits must remain valid.
destroy_pool
Release an empty pool and invalidate its identity. Live pooled/dedicated regions are rejected.
pool_statistics
Observe checked local pool accounting without native queries.
set_preferred_block_size
Configure large-heap automatic block sizing before any pool/storage creation.
set_mapping_hysteresis
Configure pooled mapping retention before native/pool acquisition.
new
Construct from caller-supplied physical-device metadata.
Prefer Self::new_from_physical_device for queried properties and the
local native-allocation count limit. Managed buffers require the device’s
owned creation capabilities; raw imports without them support only the
explicitly unsafe low-level allocation route.
Without a buffer/image granularity limit, blocks conservatively exclude
conflicting image tilings. Use Self::new_with_granularity to supply it.
Safety
Properties and atom size must belong to this device’s physical device. Caller must enforce device allocation size/count limits and enabled features.
new_retained
Construct retaining one shared device context.
The allocator owns an Arc clone of the device, so it may outlive its
construction scope and be adopted or destroyed on another thread.
Follows Self::new; callback forms stay borrowed-only.
Safety
Properties and atom size must belong to this device’s physical device. Caller must enforce device allocation size/count limits and enabled features.
new_with_granularity
Construct from memory properties and both physical-device alignment limits.
Enables mixed buffer/linear/optimal image blocks with checked granularity
page separation. Otherwise follows Self::new.
Errors
Rejects invalid memory properties, non-power-of-two limits or missing PFNs.
Safety
Properties, atom (nonCoherentAtomSize) and granularity
(bufferImageGranularity) must describe this device’s physical device.
The caller enforces native size/count limits, enabled features and lifetimes.
new_retained_with_granularity
Self::new_with_granularity retaining one shared device context.
Safety
Same metadata and native lifetime contract as new_with_granularity.
new_from_physical_device
Query properties and limits for the selected physical device.
Requires owned instance/device creation metadata and a compatible parent
snapshot. It does not discover a logical device’s physical-device identity.
Queries the maximum allocation size when core 1.1 or enabled maintenance3
provides it. Legacy 1.0 leaves this limit unknown; see Self::max_allocation_size.
The local count limit excludes allocations made by other allocators/raw calls.
Safety
physical_device must belong to instance and be the physical device used
to create device. All contexts must remain live; native ownership and
host synchronization remain the caller’s responsibility. Unqueried size
limits and resource valid usage must still be observed by the caller.
new_retained_from_physical_device
Self::new_from_physical_device retaining one shared device context.
Safety
physical_device must belong to instance and be the physical device used
to create device. Native ownership and host synchronization remain the
caller’s responsibility.
new_with_callbacks
Construct with borrowed callbacks for native effects and CPU metadata. Callback storage is borrowed for the allocator’s complete borrow lifetime.
Errors
Same metadata/PFN errors as new; rejects missing host allocation/free functions.
Safety
All new requirements apply. Callbacks/user data must remain valid and
satisfy Vulkan alignment, thread, reentrancy and non-unwinding contracts.
They are used consistently for native allocation, creation and rollback;
CPU metadata uses the allocation/free pair with OBJECT scope. The inline
allocator and non-owning tokens need no heap identity. Returned Vec output
collections and caller-owned writers retain their Rust allocation policy.
Callback free may run while host metadata is dropped; it never frees
native Vulkan objects implicitly.
new_from_physical_device_with_callbacks
Query limits and retain matching caller-owned native allocation callbacks.
Errors
Same provenance/property/PFN errors as new_from_physical_device.
Safety
Match the physical-device constructor’s identity/lifetime contract and the
callback lifetime/alignment/thread/reentrancy contract of new_with_callbacks.
live_count
is_closed
max_allocation_size
Queried native per-allocation size ceiling, or unknown on the caller-supplied metadata route and legacy 1.0 without admitted maintenance3 properties. A known ceiling is not a promise of available heap space or allocation success.
close
Close only when all allocations have been explicitly released; repeat close succeeds.
allocate
Allocate separate native storage without a resource-specific allocation chain.
Safety
Request must satisfy resource requirements and device size/count limits. External and required-dedication semantics are excluded. Protected storage requires captured enabled feature metadata and explicit required flags. Owned core/KHR device-address enablement automatically flags raw storage.
free
Safety
Destroy every bound resource and complete all GPU/host accesses first.
map
Acquire one explicit mapping hold; every successful call needs one unmap.
Safety
Synchronize host/GPU access; returned pointers cannot outlive the mapping.
unmap
Safety
No pointer into this mapping may be used after unmapping.
flush
Safety
Mapping and accesses must satisfy Vulkan host/device synchronization rules.
invalidate
Safety
Complete device writes before invalidating and do not race host accesses.
create_buffer
Create, allocate and bind an ordinary buffer transactionally.
Safety
Info must satisfy device limits/valid usage. Sparse, external and arbitrary pNext chains are not admitted. Protected resources need captured enabled feature metadata and matching creation flags. Device-address usage requires captured enabled core/KHR feature metadata.
destroy_buffer
Destroy a matching managed buffer before freeing its allocation.
Safety
Complete every CPU/GPU use; do not separately destroy this buffer first. The buffer must use this allocator’s callbacks; otherwise destroy it directly then free.
create_buffer_with_options
Create and bind an ordinary buffer using explicit separate/pooled policy.
Safety
Same native valid-usage, completion and synchronization obligations as create_buffer.
create_image
Create and bind an image using separate storage and explicit memory properties.
Safety
All image/create-chain valid usage and host/GPU lifetimes remain caller obligations.
create_image_with_options
Create, allocate and bind an image using explicit or automatic memory policy.
Safety
Match native image, feature, pointer-chain and synchronization valid usage.
destroy_image
Destroy a managed image and release its allocation after exact completion.
Safety
Destroy views first; complete all host/GPU uses and end explicit maps. The image must use this allocator’s callbacks; otherwise destroy it directly then free.
mapped_pointer
Observe a current explicit or persistent mapping without acquiring a hold.
allocation_info
Query checked binding metadata and this region’s current mapping without native calls.
Errors
Returns Closed, WrongAllocator or UnknownAllocation for invalid identity/state.