Closed by Uli Schlachter (psychon)
Friday, 17 September 2010, 13:51 GMT Reason for closing: FixedAdditional comments about closing: If there are still some leaks, please
open a new bug report with an approriate
test case. This leak is gone for good.
:)

While drawing the wibox, the C core
builds up a list of widgets and their
associated geometry. This list
consists of widget_node_t objects and
is
constructed like this (This is from
luaA_table2widgets()):

After we are done with this list of
widget nodes, it is freed via
wibox_widget_node_array_wipe().
However, wibox_widget_node_array_wipe()
passed
"&w" to
luaA_object_unref_item() while it should
have used "w.widget" (which
is
what was returned from
luaA_object_ref_item()). This made the
unref fail and the
wibox was carrying around a
reference to this widget forever. This
was
effectively a memory leak.

Since I had no clue where to start, I tried coming up with some test case that shows growing memory usage (feel free to do the same).
Here's the result: (Both top and the collectgarbage("collect") call show growing memory usage)

if buttons then
-- Use a local variable so that the garbage collector doesn't strike
-- between now and the :buttons() call.
local btns = data[o]
if not btns then
btns = {}
data[o] = btns
for kb, b in ipairs(buttons) do
-- Create a proxy button object: it will receive the real
-- press and release events, and will propagate them the the
-- button object the user provided, but with the object as
-- argument.
local btn = capi.button { modifiers = b.modifiers, button = b.button }
btn:connect_signal("press", function () b:emit_signal("press", o) end)
btn:connect_signal("release", function () b:emit_signal("release", o) end)
btns[#btns + 1] = btn
end
end
ib:buttons(btns)
tb:buttons(btns)
end

I just noticed that my last post doesn't show growing memory usage in top and wondered "why isnt out __gc method called?".

@jd:
luaA_table2wtable() replaces the metatable of everything in the table so that our own __index method is called. Could it be that this replaces the metatable on the widget and thus we lose track of the widget?