Analyzer lj-free-stats

Name

lj-free-stats - Statistics of free chunks for LuaJIT’s builtin Allocator

This analyzer profiles the memory allocation behavior of LuaJIT’s built-in allocator in applications such as OpenResty and Kong. It captures statistics on free memory chunks including size distribution, fragmentation patterns, and allocation efficiency. The analyzer generates histogram visualizations showing the distribution of free chunk sizes, enabling developers to diagnose memory fragmentation issues, optimize memory usage patterns, and prevent memory-related performance degradation.

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-free-stats -p PID

# trace a shell command directly
orxray analyzer run lj-free-stats -c SHELL_CMD

Tracing Multiple Processes

Not supported.

Output Formats

  • Histogram Bar Charts
  • Plain Texts

Output Example

{
  "distributions": {
    "http": [
      { "count": 0, "key": "16" },
      { "count": 0, "key": "32" },
      { "count": 1, "key": "64" },
      { "count": 16, "key": "128" },
      { "count": 5, "key": "2048" },
      { "count": 9, "key": "4096" },
      { "count": 3, "key": "8192" },
      { "count": 1, "key": "65536" }
    ]
  },
  "http": {
    "min": 96,
    "max": 111960,
    "count": 36,
    "sum": 232928
  }
}

Author

The OpenResty Inc. Team.

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