Analyzer lj-gco-cdata-stats

Name

lj-gco-cdata-stats - CData Object Statistics by CData Type

This analyzer provides detailed statistics about CData objects in LuaJIT-based applications such as OpenResty and Kong. CData objects are LuaJIT’s FFI (Foreign Function Interface) data structures that hold C data types. The analyzer captures and categorizes all CData objects by their C type definitions, generating table charts that show the count and memory usage of each CData type. This helps identify FFI usage patterns, detect excessive CData allocations, and optimize memory usage in applications that heavily use LuaJIT’s FFI capabilities.

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

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

Tracing Multiple Processes

Not supported.

Output Formats

  • Tables
  • Plain Texts

Output Example

[
  {
    "title": "",
    "type": "table",
    "data": [
      ["CData Type", "CData Count"],
      ["int ()", "18"],
      ["void ()", "10"],
      ["ctype", "10"],
      ["int [1]", "9"],
      ["uint64_t ()", "7"],
      ["unsigned char *[1]", "5"],
      ["int64_t ()", "3"],
      ["unsigned int ()", "3"],
      ["unsigned char [?]", "3"],
      ["void *[1]", "2"],
      ["double ()", "2"],
      ["struct 97 [1]", "1"],
      ["struct ngx_http_lua_script_engine_s **()", "1"],
      ["double [1]", "1"],
      ["struct 181 *()", "1"],
      ["void *()", "1"],
      ["char *[1]", "1"],
      ["uint64_t [1]", "1"],
      ["const char *()", "1"],
      ["int64_t [1]", "1"]
    ],
    "ver": 1
  }
]

Author

The OpenResty Inc. Team.

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