Strings in luajit are infinitely bloated, even if they are not rereferenced in the lua vm

41 views
Skip to first unread message

xue

unread,
Aug 25, 2024, 6:26:24 AMAug 25
to openresty-en
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.

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)

xue

unread,
Aug 25, 2024, 6:26:24 AMAug 25
to openresty-en
xue
16:33 (1小时前) 
收件人 openresty
Reply all
Reply to author
Forward
0 new messages