#Memory leaks

1 messages · Page 1 of 1 (latest)

shell island
#

just out of curiosity, whats a common mistake made that results in memory leaks. What should be done to avoid them. And whats a good habit to take to optimize performance overall

swift goblet
#

A good way to prevent such leaks is by simply trying to avoid such calls, and when you do actually need them, then make sure that there is no way for it to constantly call itself

cursive gazelle
#

that is called recursion and is absolutely not a memory leak

#

you cannot not yield when calling a function

#

unless you explicitly cast it to a parallel thread, which is stupid in any case

#

a memory leak on Roblox can happen in many ways but it's most common for people to cause them when they connect to events inside of events or other reused code like functions without disconnecting previous connections

#

a great example is RunService.PostSimulation:Connect(function()
RunService.PostSimulation:Connect(function()

end)
end)

#

and I have legitimately seen this bs

#

and module recursive requires will error regardless

shell island
#

wait so like when i fire an event from client to server, and run some code is some function, i have to disconnect the function?

#

im not sure i got everything

#
function module:PlayAnimation(char : Model)
  HumanoidAnimTrack:GetMarkerReachedSignal("CamFade"):Connect(function()
  --yappatron [...]
end
end

here i'd have to discornnect the get marker reached signal event?

echo quarry
echo quarry
#

usually yeah

echo quarry
# shell island like ever?

eg. if I had some kind of checkpoint trigger that I connect to a part.touched event, then I'd disconnect it afterwards since I don't expect to need it anymore (assuming you can't backtrack)

shell island
#

oh okay i got it