ZonePlus icon indicating copy to clipboard operation
ZonePlus copied to clipboard

`self.janitor:add(Janitor.new(), "destroy")` memory leaks

Open wrello opened this issue 3 months ago • 0 comments

Occurences of:

self.janitor:add(Janitor.new(), "destroy")

are memory leaks if once the inner janitor is destroyed it doesn't get removed from the outer janitor.

They need the following pattern:

local janitor, objectIndex = self.janitor:add(Janitor.new(), "destroy")
janitor:add(function()
    self.janitor:remove(objectIndex)
end)

wrello avatar Sep 26 '25 01:09 wrello