Expand description
The one counting allocator of a debug build (the global feature):
a #[global_allocator] crate::CountingAlloc::with_tags over
std::alloc::System, and reading and rows, which read it.
What it counts goes under the tags the program enters
(crate::tags): shuyi-app and shuyi-cli enter the frame’s
phases, the game’s spans and each asset kind’s decode.
Why it is here. A binary has one global allocator: two
#[global_allocator] statics in it don’t link. shuyi-app (a game’s
window) and shuyi-cli (its tool program) both count the heap, and a
tool program links both. So neither declares the static: both turn on
this feature, Cargo unifies it, and the binary gets this one static.
When it counts. In a debug build (debug_assertions), unless the
game builds with --cfg shuyi_no_heap_count, which a game with a
global allocator of its own sets in its .cargo/config.toml’s
rustflags (the crate’s docs show how). A release build has no static
at all: the program allocates with std::alloc::System directly,
as if this crate weren’t there.
It counts the whole process: every thread’s allocations, not only the game’s.
Constants§
- COUNTING
- Whether this build counts the heap: a debug build without
--cfg shuyi_no_heap_count.
Functions§
- reading
- The heap’s counts now, the calls since the last reading taken;
Nonein a build that doesn’t count (COUNTING). - rows
- The heap’s counts by tag now (
CountingAlloc::rows);Nonein a build that doesn’t count (COUNTING).