Expand description
Debug leak counters behind the leak-check cargo feature.
With the feature on, the runtime counts every resource it hands to a
consumer and every release, so a test harness can assert that a consumer
released everything it was given (after forcing its garbage collector or
finalizers to run). export_runtime! exports the counters as
uint64_t {prefix}_debug_live(int32_t kind).
The symbol is exported whether or not the feature is on, so a consumer
never has to know how the producer was built: without the feature every
counter reads 0. Ask for kind COUNTING (-1) to tell “nothing is
live” from “nothing is counted”.
Constants§
- ALLOCATIONS
- Returned string, bytes, and value-buffer allocations (including error
payloads) that haven’t been passed to
{prefix}_free_bytes. - CALLBACKS
- Consumer callback-interface implementations the producer still holds
(each is released through the vtable’s
freeentry). - COUNTING
- The pseudo-kind
{prefix}_debug_liveanswers with1when the producer counts live resources (ENABLED) and0when it doesn’t. - ENABLED
- Whether this build counts live resources (the
leak-checkfeature). - ITERATORS
- Iterator handles a launcher returned that haven’t been destroyed.
- OBJECTS
- Interface object references held by the consumer: one per pointer a
thunk returns, per
_clone, and per object token written into a value buffer; released by_destroyand by adopting a token. - TOKENS
- Cancel-token references, both the consumer’s (
createuntildestroy) and the producer’s (one per in-flight cancellable call).
Functions§
- debug_
live - The body of
{prefix}_debug_live: how many resources ofkind(one ofOBJECTS,CALLBACKS,ITERATORS,TOKENS, orALLOCATIONS) are live right now, or, forCOUNTING,1when this build counts at all.