1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Allocation intent tags.
#![allow(deprecated)] // Internal uses of deprecated types are intentional
/// Describes the intended lifetime and usage of an allocation.
///
/// This allows the allocator to route allocations to the optimal backend.
#[deprecated(
since = "0.11.1",
note = "framealloc is deprecated. Use `memkit::MkIntent` instead (available in memkit 0.12+)"
)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum AllocationIntent {
/// Frame-temporary allocation.
///
/// Lives only until `end_frame()` is called.
/// Uses bump allocation - extremely fast.
Frame,
/// Short-lived allocation from object pool.
///
/// Should be explicitly freed when done.
/// Uses thread-local free lists.
Pool,
/// Long-lived allocation.
///
/// Uses the system heap.
/// Should be explicitly freed when done.
Heap,
}
impl Default for AllocationIntent {
fn default() -> Self {
Self::Frame
}
}
/// A tag for categorizing allocations for budgeting and tracking.
///
/// Custom tags can be used to track memory usage by subsystem.
#[deprecated(
since = "0.11.1",
note = "framealloc is deprecated. Use `memkit::MkTag` instead (available in memkit 0.12+)"
)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AllocationTag {
name: &'static str,
}
impl AllocationTag {
/// Create a new allocation tag.
pub const fn new(name: &'static str) -> Self {
Self { name }
}
/// Get the tag name.
pub fn name(&self) -> &'static str {
self.name
}
}
// Common predefined tags
impl AllocationTag {
pub const RENDERING: Self = Self::new("rendering");
pub const PHYSICS: Self = Self::new("physics");
pub const AUDIO: Self = Self::new("audio");
pub const SCRIPTING: Self = Self::new("scripting");
pub const ASSETS: Self = Self::new("assets");
pub const UI: Self = Self::new("ui");
pub const NETWORKING: Self = Self::new("networking");
pub const GENERAL: Self = Self::new("general");
}