Skip to main content

Module leak

Module leak 

Source
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 free entry).
COUNTING
The pseudo-kind {prefix}_debug_live answers with 1 when the producer counts live resources (ENABLED) and 0 when it doesn’t.
ENABLED
Whether this build counts live resources (the leak-check feature).
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 _destroy and by adopting a token.
TOKENS
Cancel-token references, both the consumer’s (create until destroy) and the producer’s (one per in-flight cancellable call).

Functions§

debug_live
The body of {prefix}_debug_live: how many resources of kind (one of OBJECTS, CALLBACKS, ITERATORS, TOKENS, or ALLOCATIONS) are live right now, or, for COUNTING, 1 when this build counts at all.