generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: What does collect garbage do?

Previous Thread :: Next Thread 
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
17 Jul 2015 01:51 PM
Title
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
17 Jul 2015 01:51 PM
if it's above 0...

u need to take ur garbage out
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
17 Jul 2015 01:52 PM
It disposes of garbage. (Exempli gratia, unused variables)
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
17 Jul 2015 01:54 PM
I also did some research about it, but I couldn't understand too much about it.

So for example:
collectgarbage()
for i = 1, 100 do
a = a
end

Will that stop the for loop?
Thanks.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
17 Jul 2015 01:55 PM
Of course not. It only collects the garbage, not modifies the flow of your script.
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
17 Jul 2015 01:56 PM
Ok thanks.
So its basicly a way to stop 'lag'?
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
17 Jul 2015 01:57 PM
what? no that won't stop the loop at all

garbage collection doesn't get rid of unused variables, it gets rid of the data it holds. if you have a function or a table that is no longer being referenced to, the lua vm is going to clear it from memory (RAM usually) so it can be repurposed

so
x = {wdfwe other data etc}
x = nil

now that table the x originally held is gone (assuming there are no other references to it)
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
17 Jul 2015 01:58 PM
and sort of, if the lag is a result of low memory reserves then it'd help. you only have so much memory and you don't want it all wasted on unused stuff.
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
17 Jul 2015 01:58 PM
Oh so it also keeps the previous storage?
That's cool.

Thanks for the explanation.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
17 Jul 2015 01:59 PM
Highly unfortunately, the __gc metamethod is not available for use, so we can't do cool things with it.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
17 Jul 2015 01:59 PM
"Oh so it also keeps the previous storage?"
not sure what you mean
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
17 Jul 2015 02:01 PM
@lord
For example:
a = "Hello";
a = nil;

Is the "Hello" now also somewhere stored?
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
17 Jul 2015 02:03 PM
no u changed the value

itz gone boi
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
17 Jul 2015 02:04 PM
Nooooo :'(
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
17 Jul 2015 02:04 PM
5 evr
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
17 Jul 2015 02:04 PM
Nope. It's not gone when you set a variable to nil.

At least, I don't think it is.
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
17 Jul 2015 02:05 PM
Oh god, what do we do.
Tell Abstract that he is wrong.
Its still in the source code!
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
17 Jul 2015 02:06 PM
Nope, hello is now gone from memory. Strings, numbers, and bools are all primitive data though so it can't be referenced anyway.

Like a table is an object so
tab = {"x", "y"}
tab2 = tab

there is only one table in memory, and the VM is going to keep track of both of those variables.

so if I do
tab[3] = "z"
print(tab2[3])

you'd get z, even though you set by using it's other pointer

but str = "sdf"
str2 = str

you now have two different strings stored in memory

hopefully that helps some
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
17 Jul 2015 02:06 PM
u hacker
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
17 Jul 2015 02:06 PM
Ok sorry can't follow anymore.
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
17 Jul 2015 02:07 PM
@Abstract
knockknock
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
17 Jul 2015 02:08 PM
whodere
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
17 Jul 2015 02:11 PM
le popo
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
17 Jul 2015 02:11 PM
le popo hooooo
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
17 Jul 2015 02:12 PM
collectgarbage()
bai bai popo
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image