Skip to main content

lje.gc

Low-level garbage collector inspection and manipulation.

Functions

lje.gc.get_total()

Returns the GC's current tracked memory total in bytes.

Returns

TypeDescription
integer

The number of bytes currently tracked by the GC.

lje.gc.set_total(bytes)

Directly overrides the GC's tracked memory total. Useful for hiding allocations from GC pressure calculations. Use with care — setting this too low can cause the GC to trigger too aggressively; too high and it may never trigger.

Parameters

NameTypeDescription
bytesinteger

The value to set as the GC total.

lje.gc.run_full_gc()

Immediately triggers a full GC collection cycle.

lje.gc.begin_track()

Begins a GC tracking window. Records sentinels for the current GC root list and userdata list, saves the current GC total and threshold, then freezes the GC threshold to prevent any collection during the window. Must be paired with lje.gc.end_track. Nesting is not supported — calling this while a window is already active is an error.

Errors

  • gc tracking already active

lje.gc.end_track()

Ends a tracking window started by lje.gc.begin_track. Tags all objects allocated during the window with an internal LJE marker, then restores the original GC totals and threshold. Applies compensating GC pressure proportional to the hidden allocation size so that external observers see normal GC behavior. Calling this without an active tracking window is an error.

Errors

  • gc tracking not active