Analyzer lj-gc-state

Name

lj-gc-state - LuaJIT GC configuration and runtime state

This analyzer extracts and displays the garbage collector (GC) configuration and current runtime state of LuaJIT virtual machines in applications such as OpenResty, Kong, and APISIX. It captures GC tuning parameters (setpause and setstepmul), the GC stop flag, the current GC phase (e.g., pause, propagate, atomic, sweepstring, sweep, finalize), and key memory metrics including total allocated bytes, the next collection threshold, and the estimated amount of memory in use. The analyzer supports both the HTTP and Stream Lua modules in OpenResty. Results are presented as a compact table, enabling administrators to verify GC tuning, compare GC behavior across instances, and diagnose memory growth or GC-related performance issues at runtime.

Resource Category

Miscellaneous.

Application Type & Technical Stack

  • OpenResty
  • Kong
  • APISIX

Command Line Syntax

The analyzer can be invoked directly on the command-line via the orxray utility from the openresty-xray-cli software package.

Alternatively, the analyzer can also be invoked manually or automatically on the web console UI of OpenResty XRay (like on the Advanced web page).

# PID is the target process PID.
orxray analyzer run lj-gc-state -p PID

# trace a shell command directly
orxray analyzer run lj-gc-state -c SHELL_CMD

Tracing Multiple Processes

Not supported.

Output Formats

  • Plain Texts

Output Example

[
  {
    "type": "table",
    "title": "LuaJIT GC config and state",
    "ver": 1,
    "data": [
        [ "Item", "value" ],
        [ "GC setpause", "200" ],
        [ "GC setstepmul", "200" ],
        [ "GC stop", "false" ],
        [ "GC state", "sweepstring" ],
        [ "GC total", "34246925" ],
        [ "GC threshold", "34247277" ],
        [ "GC estimate", "33645257" ]
    ]
  }
]

Author

The OpenResty Inc. Team.

Copyright (C) by OpenResty Inc. All rights reserved.