openresty / openresty/luajit2

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

Open
#242 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.4k
Forks
252
Avg merge
7d 11h
Merged PRs (30d)
3

Description

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)

`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal resty example.lua and compare collectgarbage("count") before and after the full collection. Investigate how the reported strings affect the nginx process RES after the Lua VM no longer references them. Done means the reported memory growth is explained and the underlying retention behavior is corrected or documented with a reproducible check.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, nginx
Domain
backend, performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.