hxn

Gc

Garbage collection control for native memory, which the collector cannot measure.

A native value is released by close(), or by the collector when its Haxe object is no longer reachable. The collector runs when the memory it manages has grown. A Haxe object that holds a native value counts as a few words of that memory, however much native memory the value holds. Two mechanisms compensate:

  • collect runs a collection immediately, with the same call on every runtime;
  • a library reports how many bytes its values hold, and its Meter runs a collection when that total has grown. A binding checks the meter whenever it creates an object of an interface the library marked as weighed.

close() remains the way to release a value at a known time.

Static fields

var budget:Float

The number of bytes a library's values may hold before a collection is run for them. After a collection, the next one runs at twice the bytes still held, if that is more than this.

Static methods

function collect():Bool

Runs a full collection now. Returns false where the runtime cannot be forced to run one, which is hxcpp under Emscripten.

function check():Void

Checks every library's meter. Loop.sync calls this, and so does a binding when it creates a weighed object.