Re: upvalue memory leak.

  • From: Mike Pall <mike-1208@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 17 Aug 2012 02:01:08 +0200

Robert G. Jakabosky wrote:
> I had noticed this issue when working on the last test-case.  Almost forgot 
> about it.  Attached is a simplified test-case that show how a closure's 
> upvalue is not collected (maybe the closure is also not collected, not sure).
> The standard Lua VM will free the memory used by the upvalue, so I am sure 
> that the references to the memory have been released and it should be 
> collectable.
> Disabling the JIT allows the memory to be collected, so I guess the JIT 
> compiled code is keeping a reference to the table and keeping it from being 
> collected.

The upvalue is immutable, so its value is constified as part of a
trace. Traces are attached to the prototype, not to individual
closures. When the prototype is collected, the traces will be
collected, too.

There's no easy way to avoid that. But I don't think this issue
matters much for non-synthetic code, though.


Other related posts: