IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
| |
|
|
| 17 Jul 2015 01:51 PM |
if it's above 0...
u need to take ur garbage out |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2015 01:52 PM |
| It disposes of garbage. (Exempli gratia, unused variables) |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 17 Jul 2015 01:55 PM |
| Of course not. It only collects the garbage, not modifies the flow of your script. |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 17 Jul 2015 02:03 PM |
no u changed the value
itz gone boi |
|
|
| Report Abuse |
|
|
IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
| |
|
| |
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
| |
|
IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
|
| 17 Jul 2015 02:06 PM |
| Ok sorry can't follow anymore. |
|
|
| Report Abuse |
|
|
IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
| |
|
| |
|
IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
| |
|
| |
|
IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
|
| 17 Jul 2015 02:12 PM |
collectgarbage() bai bai popo |
|
|
| Report Abuse |
|
|