Page 1 of 1
Quick question: Discarding unused resources?
Posted: Sun Jun 08, 2014 6:52 pm
by Suppercut
How would I unload graphics or sounds? Does the garbage collector do it (as in setting all its reference indices to nil so it becomes unused)?
Re: Quick question: Discarding unused resources?
Posted: Sun Jun 08, 2014 7:28 pm
by slime
Yep, if there are no more references to an object, then the garbage collector will take care of it eventually. If you want it to happen immediately, you can force a couple garbage collection cycles with: collectgarbage() collectgarbage().
Re: Quick question: Discarding unused resources?
Posted: Mon Jun 09, 2014 4:07 am
by Suppercut
And this will remove the resource itself from memory, not just the object associated with it? So if I remove all references to an Image or Canvas, eventually the graphics card memory will be freed?
Re: Quick question: Discarding unused resources?
Posted: Mon Jun 09, 2014 4:11 am
by slime
Yep, as long as other LÖVE functions don't hold references to it. For example if an Image is used by a SpriteBatch then it won't be completely deleted at least until the SpriteBatch is deleted as well.
Re: Quick question: Discarding unused resources?
Posted: Mon Jun 09, 2014 4:15 am
by Suppercut
Alright, thanks mate!