Skip to content

bug: Strings in luajit are infinitely bloated, even if they are not rereferenced in the lua vm #11519

@fairyqb

Description

@fairyqb

Current Behavior

Minimal example code

resty example.lua

`
local function get_memory_usage()
local b = collectgarbage("count") * 1024
return b
end

local my_table = {}  
for i = 1, 10000000 do  
    my_table[i] =  string.rep("A" , 256) .. i  

end

my_table = nil
print("start gc:", "mem:",get_memory_usage())
collectgarbage("collect") 
print("end gc:", "mem:",get_memory_usage())
print("sleep 10m")

print("done")
ngx.sleep(60*10*6)

`

Strings in luajit are infinitely bloated, even if they are not rereferenced in the lua vm. As a result, the memory resources of the nginx process RES are increasing to become larger and larger.

Expected Behavior

why?

Error Logs

none

Steps to Reproduce

none

Environment

  • APISIX version (run apisix version):
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):
    aspsix all version

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions