GC

private class
system.GC

Description

The GC Class provides methods for invoking the LoomScript Garbage Collector.

API overview

Constructor

GC ()

Constants

Constants

COLLECT: Number static

Performs a full garbage-collection cycle

COUNT: Number static

Returns the current amount of memory (in Kbytes) in use by the Lua VM

COUNTB: Number static

Returns the remainder of dividing the current amount of bytes of memory in use by Lua by 1024

RESTART: Number static

Restarts the garbage collector

SETPAUSE: Number static

Sets data as the new value for the pause of the collector (see §2.10)

SETSTEPMUL: Number static

Sets data as the new value for the step multiplier of the collector (see §2.10)

STEP: Number static

Performs an incremental step of garbage collection

STOP: Number static

Stops the garbage collector

Functions

Public functions

collect ( cmd: Number = , data: Number = 0 ): Void static native

Forces the Garbage collection process

fullCollect (): Void static

Does a full garbage collection cycle

getAllocatedMemory (): Number static native

Gets the amount of RAM allocated by the VM in mebibytes (MiB)

setMemoryWarningLevel ( megabytes: Number ): Void static native

Sets a warning level in megabytes for the VM If the VM exceeds this level a warning will be displayed in the console

update (): Void static native

Runs a frame of GC collection (incremental), there is internal logic which will back off the GC if it is spiking

Constructor

GC ()

Constants

COLLECT: Number

static

Performs a full garbage-collection cycle.

COUNT: Number

static

Returns the current amount of memory (in Kbytes) in use by the Lua VM.

COUNTB: Number

static

Returns the remainder of dividing the current amount of bytes of memory in use by Lua by 1024.

RESTART: Number

static

Restarts the garbage collector.

SETPAUSE: Number

static

Sets data as the new value for the pause of the collector (see §2.10). The function returns the previous value of the pause.

SETSTEPMUL: Number

static

Sets data as the new value for the step multiplier of the collector (see §2.10). The function returns the previous value of the step multiplier.

STEP: Number

static

Performs an incremental step of garbage collection. The step "size" is controlled by data (larger values mean more steps) in a non-specified way. If you want to control the step size you must experimentally tune the value of data. The function returns 1 if the step finished a garbage-collection cycle.

STOP: Number

static

Stops the garbage collector.

Functions

collect ( cmd: Number = , data: Number = 0 ): Void

static native

Forces the Garbage collection process. The default is to do a STEP (incremental) collection.

Parameters

cmd: Number =
data: Number = 0


fullCollect (): Void

static

Does a full garbage collection cycle.



getAllocatedMemory (): Number

static native

Gets the amount of RAM allocated by the VM in mebibytes (MiB)



getFullTypeName (): String
Inherited from Object

native

Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.


Returns

String fully qualified type name of the Object.

getType (): Type
Inherited from Object

native

Gets the Type that describes the Object.


Returns

Type The Type that describes the object.

getTypeName (): String
Inherited from Object

native

Gets the type name of the Object.


Returns

String type name of the Object.

setMemoryWarningLevel ( megabytes: Number ): Void

static native

Sets a warning level in megabytes for the VM If the VM exceeds this level a warning will be displayed in the console. Please note that this warning level is purely for the scripting VM and not other assets that may be loaded.

Parameters

megabytes: Number The memory threshold in megabytes that causes a warning when surpassed


toString (): String
Inherited from Object

native

Returns a String that describes the Object. This can be overriden to provide extra details when printing objects using trace().


Returns

String String that described the Object.

update (): Void

static native

Runs a frame of GC collection (incremental), there is internal logic which will back off the GC if it is spiking. Note that the Loom Application class calls this internally. If you want to do a full collection, use GC.fullCollect();



: