GC
GC is the garbage collector of the script’s memory: the strings, arrays, maps and instances
it makes. It collects on its own, and before memory would cross the project’s
vm_memory_limit (see Configuration), so a script rarely
needs it. The geometry kernel’s meshes aren’t script memory.
collect
Section titled “collect”GC.collectRuns a collection now, freeing what the script no longer holds. Returns: nil.
bytes_allocated
Section titled “bytes_allocated”GC.bytes_allocatedHow many bytes of script memory the collector holds now. Returns: Number.
before = GC.bytes_allocatedscratch = (0...10000).map { |i| [i, i * 2] }scratch = nilGC.collectputs GC.bytes_allocated <= before + 100_000 # true