ZonePlus icon indicating copy to clipboard operation
ZonePlus copied to clipboard

Memory leak if parts get destroyed in a zone

Open wrello opened this issue 4 months ago • 2 comments

function Zone:_partTouchedZone(part)
	local trackingDict = self.trackingTouchedTriggers["part"]
	if trackingDict[part] then return end
	local nextCheck = 0
	local verifiedEntrance = false
	local enterPosition = part.Position
	local enterTime = os.clock()
	local partJanitor = self.janitor:add(Janitor.new(), "destroy")
	trackingDict[part] = partJanitor

	janitor:add(part.Destroying:Connect(function() -- This addition fixes the memory leak.
		trackingDict[part]:destroy()
	end), "Disconnect")

        ...
end

wrello avatar Aug 12 '25 00:08 wrello

Thanks for the report

1ForeverHD avatar Aug 19 '25 17:08 1ForeverHD

Using partJanitor:linkToInstance(part) is a better way to fix this here

wrello avatar Sep 26 '25 01:09 wrello