Gc

gdext.internal.Gc
object Gc

Control over the Scala Native garbage collector (Boehm, stop-the-world, single-threaded — the GC the sbt plugin always configures).

Engine objects never depend on the GC: their lifetimes follow Godot (scene tree, free(), owned RefCounted references), so collecting, pausing or resuming the GC never frees a Godot object. What the GC reclaims is plain Scala heap: wrappers, closures, strings, collections, math values.

Typical game use: Gc.collect() at a loading screen or level transition, and Gc.paused { ... } around a short burst that must not stutter. Reached as gdext.api.Gc.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Gc.type

Members list

Type members

Classlikes

final case class Stats(heapBytes: Long, totalAllocatedBytes: Long, collections: Long, outstandingOwnedRefs: Long)

A snapshot of the collector's counters.

A snapshot of the collector's counters.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def collect(): Unit

Run a full collection now.

Run a full collection now.

Attributes

def collections: Long

Number of collections run since start-up.

Number of collections run since start-up.

Attributes

def disable(): Unit

Stop automatic collections until a matching enable. Calls nest: the GC runs again only once every disable has been matched. The heap grows instead of collecting while disabled.

Stop automatic collections until a matching enable. Calls nest: the GC runs again only once every disable has been matched. The heap grows instead of collecting while disabled.

Attributes

def enable(): Unit

Undo one disable.

Undo one disable.

Attributes

def heapBytes: Long

Current GC heap size in bytes.

Current GC heap size in bytes.

Attributes

inline def paused[A](inline body: A): A

Run body with automatic collections paused, re-enabling on exit.

Run body with automatic collections paused, re-enabling on exit.

Attributes

def stats: Stats

Bytes allocated on the GC heap since start-up (monotonic).

Bytes allocated on the GC heap since start-up (monotonic).

Attributes