Quick question: Discarding unused resources?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Quick question: Discarding unused resources?
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)?
- slime
- Solid Snayke
- Posts: 3161
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Quick question: Discarding unused resources?
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?
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?
- slime
- Solid Snayke
- Posts: 3161
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Quick question: Discarding unused resources?
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?
Alright, thanks mate!
Who is online
Users browsing this forum: No registered users and 6 guests