Analyzer resty-memory
Name
resty-memory - Application-Level Memory Usage Breakdown
This analyzer profiles application-level memory usage breakdown for LuaJIT-based applications such as OpenResty and Kong. It captures detailed memory allocation information across different memory regions including LuaJIT GC-managed memory, LuaJIT allocator memory, shared memory zones, glibc/musl libc heap, jemalloc mapped memory, and VM regions (executable, library, stack). The analyzer generates pie charts that visualize the distribution of memory usage across these different allocation sources, helping identify memory consumption patterns and optimize memory efficiency in Lua/C hybrid 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 resty-memory -p PID
# trace a shell command directly
orxray analyzer run resty-memory -c SHELL_CMD
Tracing Multiple Processes
Not supported.
Output Formats
- Pie Charts
- Plain Texts
Output Example
{
// Shared memory module mappings - which nginx module owns each shm zone
"shm-modules": {
"ngx_accept_mutex_ptr": "ngx_events_module"
},
"total-mmaps": {}, // Total memory-mapped regions discovered
// Total shared memory zones with their sizes (in bytes)
"total-shms": {
"ngx_accept_mutex_ptr": 4096
},
// Memory-mapped regions that are currently loaded/active
"loaded-mmaps": {},
// Aggregated memory usage breakdown by category
"summary": {
"vm_data": 2813952,
"vm_file": 131072,
// musl libc heap allocation (0 means glibc is being used)
"musl_libc_heap": 0,
// jemalloc memory-mapped regions (0 means jemalloc not in use)
"jemalloc_mmaped": 0,
// LuaJIT allocator memory for HTTP subsystem
"http_luajit_allocator": 494941,
// LuaJIT allocator memory for Stream subsystem
"stream_luajit_allocator": 0,
// Free memory in HTTP LuaJIT allocator pool
"http_luajit_free": 142080,
"vm_lib": 3936256,
"vm_exe": 1470464,
"vm_stack": 135168,
"text_segments": 5406720,
// Nginx shared memory zones that are loaded
"nginx_shm_loaded": 4096,
// glibc allocator total memory
"glibc_allocator": 1044480,
// Loaded mmap regions total size
"mmap_loaded": 0,
// glibc memory-mapped regions (large allocations)
"glibc_mmaped": 258048,
// Total memory across all allocators
"allocator_breakdown": 9899357,
// glibc arena memory (main heap)
"glibc_arena": 786432,
// Free memory in Stream LuaJIT allocator pool
"stream_luajit_free": 0,
// Nginx shared memory zones not currently loaded
"nginx_shm_unloaded": 0,
// Memory managed by LuaJIT GC for HTTP subsystem
"http_luajit_GC_managed": 352861,
// jemalloc allocator memory (0 means not in use)
"jemalloc_allocator": 0,
// Total nginx shared memory across all zones
"nginx_shm_total": 4096,
// Memory managed by LuaJIT GC for Stream subsystem
"stream_luajit_GC_managed": 0
},
// Shared memory zones currently loaded with their sizes
"loaded-shms": {
"ngx_accept_mutex_ptr": 4096
}
}
Author
The OpenResty Inc. Team.
Copyright
Copyright (C) by OpenResty Inc. All rights reserved.