Analyzer lj-gco-stat

Name

lj-gco-stat - Statistics for LuaJIT GC Objects

This analyzer provides comprehensive statistics about garbage collection (GC) objects in LuaJIT-based applications such as OpenResty and Kong. It captures and analyzes the distribution of different GC object types (tables, strings, functions, userdata, etc.) currently alive in the Lua VM. The analyzer generates histogram charts showing the count and memory usage of each object type, helping identify memory consumption patterns, detect memory leaks, and understand the memory footprint of Lua applications.

Resource Category

Memory.

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-gco-stat -p PID

# trace a shell command directly
orxray analyzer run lj-gco-stat -c SHELL_CMD

Tracing Multiple Processes

Not supported.

Output Formats

  • Histogram Bar Charts
  • Plain Texts

Output Example

{
  "upvalue": {"sum": 19392, "count": 404, "min": 48, "max": 48},
  "string": {"sum": 65656, "count": 1262, "min": 28, "max": 1624},
  "thread": {"sum": 1160, "count": 1, "min": 1160, "max": 1160},
  "proto": {"sum": 82437, "count": 179, "min": 120, "max": 3182},
  "cdata": {"sum": 1944, "count": 81, "min": 20, "max": 56},
  "table": {"sum": 119328, "count": 209, "min": 64, "max": 6208},
  "function": {"sum": 27160, "count": 474, "min": 40, "max": 208},
  "distributions": {
    "proto": [
      {"count": 0, "key": "16"}, {"count": 0, "key": "32"},
      {"count": 2, "key": "64"}, {"count": 69, "key": "128"},
      {"count": 62, "key": "256"}, {"count": 26, "key": "512"},
      {"count": 19, "key": "1024"}, {"count": 1, "key": "2048"},
      {"count": 0, "key": "4096"}, {"count": 0, "key": "8192"}
    ],
    "function": [
      {"count": 0, "key": "8"}, {"count": 0, "key": "16"},
      {"count": 381, "key": "32"}, {"count": 76, "key": "64"},
      {"count": 17, "key": "128"}, {"count": 0, "key": "256"},
      {"count": 0, "key": "512"}
    ],
    "cdata": [
      {"count": 0, "key": "4"}, {"count": 0, "key": "8"},
      {"count": 77, "key": "16"}, {"count": 4, "key": "32"},
      {"count": 0, "key": "64"}, {"count": 0, "key": "128"}
    ],
    "table": [
      {"count": 0, "key": "16"}, {"count": 0, "key": "32"},
      {"count": 65, "key": "64"}, {"count": 21, "key": "128"},
      {"count": 52, "key": "256"}, {"count": 44, "key": "512"},
      {"count": 22, "key": "1024"}, {"count": 4, "key": "2048"},
      {"count": 1, "key": "4096"}, {"count": 0, "key": "8192"},
      {"count": 0, "key": "16384"}
    ],
    "upvalue": [
      {"count": 0, "key": "8"}, {"count": 0, "key": "16"},
      {"count": 404, "key": "32"}, {"count": 0, "key": "64"},
      {"count": 0, "key": "128"}
    ],
    "udata": [
      {"count": 0, "key": "16"}, {"count": 0, "key": "32"},
      {"count": 5, "key": "64"}, {"count": 0, "key": "128"},
      {"count": 0, "key": "256"}
    ],
    "string": [
      {"count": 0, "key": "4"}, {"count": 0, "key": "8"},
      {"count": 115, "key": "16"}, {"count": 936, "key": "32"},
      {"count": 193, "key": "64"}, {"count": 5, "key": "128"},
      {"count": 5, "key": "256"}, {"count": 4, "key": "512"},
      {"count": 4, "key": "1024"}, {"count": 0, "key": "2048"},
      {"count": 0, "key": "4096"}
    ],
    "thread": [
      {"count": 0, "key": "256"}, {"count": 0, "key": "512"},
      {"count": 1, "key": "1024"}, {"count": 0, "key": "2048"},
      {"count": 0, "key": "4096"}
    ]
  },
  "summary": {
    "tmpbuf": 40, "main_thread": 6184, "c_type": 12808,
    "total": 352861, "string_table": 16384
  },
  "udata": {"sum": 336, "count": 5, "min": 64, "max": 80}
}

Author

The OpenResty Inc. Team.

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