Luajit memory leak bug.

  • From: Juan Carlos González Amestoy <jcgamestoy@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 27 Aug 2012 18:07:14 +0200

I think i find a bug in luajit.

On the following code:

local ffi=require('ffi')

local function buffer(n)
  return ffi.new('uint8_t[?]',n)
end

local function object(n)
  local b=buffer(n*n)

  local function test(n) -- if n>50 memory leak.
    for i=0,n do b[0]=0 end
  end

  return {
    b=b,
    test=test
  }
end

local function testCreate()
  local o=object(1024)

  o.test(50)
  o.test(100) -- if comment this line memory is released.
end

testCreate()

for i=1,10 do
  collectgarbage('collect')
  print(collectgarbage('count'))
end


If i call the 'test' method with a value greater than 50 the memory buffer
is never released (the print line prints >1000kb).

I test this in Mac Os X x64 and Linux x64.

PD: Sorry for the bad english

-- 
Juan Carlos González Amestoy

Other related posts: