collect
fn collect() -> int Import
Source: use gc::{collect}; compiler/src/builtin_docs/gc.hy Runs a full garbage collection now and returns the number of bytes freed.
Collection normally happens on its own; call this to make finalizers
(fn drop()) and weak clearing happen at a known point, for example in
tests. Values still named by live locals stay alive.
Returns#
int
Examples#
use gc::{collect};
use tests::assert;
let freed = collect();
assert!(freed >= 0);
See also#
root: Pinsvalueso the garbage collector keeps it alive while the returnedRootis reachable.get: Returns the pinned value, leaving the pin in place.unroot: Releases the pin and returns the value it held.weak: Makes a handle tovaluethat does not keep it alive.upgrade: Returns the value while it is still alive,Noneonce it was collected.heap_bytes: Returns the size of the managed heap in bytes.