Skip to main content

Module lua_limits

Module lua_limits 

Source
Expand description

Centralized Lua VM limits and configuration constants.

Mirrors Lua 5.5’s luaconf.h / llimits.h design. All magic numbers that control VM behavior are collected here for easy tuning and configuration.

Constants§

BASIC_STACK_SIZE
Initial stack capacity for new Lua states. Equivalent to 2 × LUA_MINSTACK (Lua 5.5: LUA_MINSTACK = 20).
CONCAT_STACK_BUF_SIZE
Stack-allocated buffer size for small concatenations.
CSTACKERR
Extra C-stack depth allowance granted during error-handler execution. Allows error handlers and __close metamethods to run even after a C-stack overflow.
DEFAULT_GC_MAJORMINOR
Major-to-minor GC transition threshold (percentage).
DEFAULT_GC_MINORMAJOR
Minor-to-major GC transition threshold (percentage).
DEFAULT_GC_MINORMUL
Default minor GC collection multiplier (percentage). Matches C Lua 5.5’s LUAI_GENMINORMUL = 20. A young (minor) collection will run after creating GENMINORMUL% new bytes.
DEFAULT_GC_PAUSE
Default GC pause (percentage). Controls how long GC waits before starting a new cycle. 250 = wait until memory is 2.5x the size after last collection.
DEFAULT_GC_STEPMUL
Default GC step multiplier (percentage). Controls how much work GC does per step relative to memory allocation. 200 = collect 2x the allocated speed.
EXTRA_STACK
Extra stack slots above frame_top for C function calls, temporaries, etc. Matches Lua 5.5’s EXTRA_STACK (5).
GC_SWEEPMAX
Maximum number of objects swept per single GC step.
LFIELDS_PER_FLUSH
Number of list items to flush per SETLIST instruction in table constructors. Matches Lua 5.5’s LFIELDS_PER_FLUSH.
LUAI_MAXCSTACK
Default maximum C-stack depth (Rust recursion depth). Matches C Lua 5.5’s LUAI_MAXCSTACK (200). Limits how many times we can recursively enter lua_execute, call metamethods, or call C functions.
LUAI_MAXSHORTLEN
Maximum length for “short” strings (interned in hash table). Matches Lua 5.5’s LUAI_MAXSHORTLEN.
LUAI_MAXSTACK
Default maximum stack size (number of slots). Matches Lua 5.5’s LUAI_MAXSTACK.
LUA_MAXCAPTURES
Maximum number of captures in string.find / string.gmatch patterns. Matches Lua 5.5’s LUA_MAXCAPTURES.
LUA_MINSTACK
Minimum guaranteed stack slots available to C functions. Matches Lua 5.5’s LUA_MINSTACK.
MAXCCALLS
Maximum parser recursion depth (prevents stack overflow in parser). Matches Lua 5.5’s MAXCCALLS for the parser.
MAXCCALLS_PATTERN
Maximum match recursion depth for pattern matching.
MAXINDEXRK
Maximum index for R/K operand in instructions.
MAXTAGLOOP
Maximum depth for __index / __newindex metamethod chains. Prevents infinite loops in metamethod resolution. Matches Lua 5.5’s MAXTAGLOOP.
MAXUPVAL
Maximum number of upvalues per function. Matches Lua 5.5’s MAXUPVAL.
MAXVARS
Maximum number of local variables per function. Matches Lua 5.5’s MAXVARS.
MAX_CALL_DEPTH
Default maximum Lua call-stack depth (number of call frames). This limits how deep pure-Lua calls can nest. Set high by default — the real recursion guard is LUAI_MAXCSTACK.
MAX_SRC_LEN
Maximum length of source name in error messages.
MAX_STRING_SIZE
Maximum string size (1 GB).
NO_REG
“No register” sentinel value in the compiler.
UNARY_PRIORITY
Unary operator priority in expression parser.