Assuming that the part gets destroyed at some point, then no it is not a memory leak because the do scope will delete the variable, if it was not in a scope then it would be a memory leak and you would need to set it to nil
p = nil
as for the event connection, when a part is destroyed the connections are automatically cleared
Something to also keep in mind is that if your game suffers from lag over time, and you thinkit may be be caused by a memory leak, the memory leak isn’t always your fault; roblox has historically had memory leaks in there own functions… Still though is good to check for memory leaks in your own code
There doesn’t seem to be a leak with this example.
In the example below, the memory also sits at .002. If you can explain the difference of the two I’d appreciate it! I’ve been looking for the memory leak within my game with no luck.
do
local baseplate = game.Workspace:WaitForChild("Baseplate")
baseplate.Touched:Connect(function(hit)
print("touched")
end)
end
The guy who made that post is incorrect or at the very least explained it without enough information, the way he explained his post requires a lot of assumpations to be made by the reader
The way he explained memory leaks is very strange to me so I could just be reading it wrong