Object recycling tips

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
cval
Citizen
Posts: 58
Joined: Sun Apr 20, 2014 2:15 pm
Location: Ukraine

Re: Object recycling tips

Post by cval »

marco.lizza wrote: But one should also try and reuse the userdata types, more than the objects themselves.
It is trivial for a particle emitter, since you can set any value to previously created one before with no problem, but i'm not sure about physics. Few examples - i found no way to change shape's dimensions or local points for it to be reused somewhere, and it also says that on every fixture created, shape is copied. So for now, it seems like, simple stack-structured pool would not work for physics.

So to recap this - default (strong) tables are collected only when there is no more references to them (and collection cycle happens), and weak tables can be collected on next collection cycle. Am i right?
marco.lizza
Citizen
Posts: 52
Joined: Wed Dec 23, 2015 4:03 pm

Re: Object recycling tips

Post by marco.lizza »

cval wrote:So to recap this - default (strong) tables are collected only when there is no more references to them (and collection cycle happens), and weak tables can be collected on next collection cycle. Am i right?
It isn't the table the object of the garbage-collection, but the objects/functions/whatever the are referring to by means of keys and/or values.

To sum things up again, weak-tables references doesn't count when marking "used" resources. If the last reference to an object is stored in a weak-values table (for example), at the next GC cycle it will be disposed.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], YaCy [Bot] and 4 guests