Function in gc compiler

heap_bytes

fn heap_bytes() -> int
Import
use gc::{heap_bytes};
Source: compiler/src/builtin_docs/gc.hy

Returns the size of the managed heap in bytes.

This counts only memory the VM’s garbage collector manages: not native libraries, stacks or other process memory.

Returns#

int

Examples#

use gc::{heap_bytes};
use tests::assert;
let v = Vec::from([1, 2, 3]);
assert!(heap_bytes() > 0 && v.len() == 3);

See also#

  • root: Pins value so the garbage collector keeps it alive while the returned Root is 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 to value that does not keep it alive.
  • upgrade: Returns the value while it is still alive, None once it was collected.
  • collect: Runs a full garbage collection now and returns the number of bytes freed.
↑ ↓ navigate ↵ open