What is garbage collecting and when should I manually do it and when is it automatic?
EDIT: Also what should be garbage collected to prevent memory issues?
What is garbage collecting and when should I manually do it and when is it automatic?
EDIT: Also what should be garbage collected to prevent memory issues?
i dont understand?
can you tell me a simple word or good meaning that your created this post
do you mean stuff like connections, threads, random parts that never got deleted?
A optimized script contains âgarbage collectingâ and I should implement that too.
My question is when (is it manual or automatic) and what should be garbage collected.
That way the game doesnât have to suffer memory issues like leaks.
Yes, something like that. But when are some âstuffâ automatically garbage collected, or does that never happen? Do we need to go through each variables, functions and connections to delete them?
Iâve moved this to Scripting Support since itâs not a creation. Please check which category youâre posting in.
The garbage collector collects objects/values from scripts that are no longer in use/needed by the script. For example, when you destroy an instance and remove any references to it, it gets picked up by the garbage collector. This happens automatically in Lua but in other lower-level programming languages like C, thereâs no built-in garbage collector and youâre tasked with managing memory yourself.
Lua uses a garbage collector that runs from time to time to collect dead objects when they are no longer accessible from the Lua program(script). All objects including tables, userdata, functions, thread, string and so on are subject to automatic memory management.
So basically when you set any tables, userdata, functions, thread, strings to nil or if you run Destroy() on an instance, it will be automatically garbage collected. Events on the other hand need to be manually disconnected when youâre done using them.
Garbage collecting is the concept of freeing up memory that is no longer in use. For example if you store something in a variable and then lose all references to the stored object (by leaving the scope, etc) that object is still stored in memory so the garbage collector goes through and frees its position in memory. In general, you really donât need to worry about garbage collecting at all. But if it really does bother you, just references to things you wonât use anymore and disconnect events.
You donât have to worry about GC, on Roblox we donât have any control over it.
Worry about other things that would be best for your interest.
And donât forget to use the search bar next timeâŠ
Can you explain which events? like you mean remote events? if yes then you mean any remote event ever in whole game I should a Disconnect() to it?