Remove From Memory

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.
Post Reply
koopatroopa
Prole
Posts: 6
Joined: Thu Dec 08, 2011 11:35 pm

Remove From Memory

Post by koopatroopa »

Just a quick question about performance,
when i load an image or a sound or whatever when I'm done with it to avoid filling up the ram, do i have to get rid of it somehow?

thanks
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Remove From Memory

Post by tentus »

If your variable is called foo...

Code: Select all

foo = nil
Kurosuke needs beta testers
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Remove From Memory

Post by MarekkPie »

http://lua-users.org/wiki/GarbageCollection

Here's some talk about the Garbage Collection that Lua uses. You don't need to explicitly delete stuff, Lua does it when it realizes you are no longer using it. One of those ways is by making it nil.
User avatar
slime
Solid Snayke
Posts: 3144
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Remove From Memory

Post by slime »

If you want to force a full garbage collection cycle for whatever reason, you can do so with collectgarbage("collect")

So you might have like

Code: Select all

wholebunchofimagesinatable = nil
collectgarbage("collect")
loadnewimages()
or something... It's not necessary 99% of the time though.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Remove From Memory

Post by Robin »

To make sure you don't use collectgarbage('collect') unnecessarily: if you have to ask, you shouldn't use it.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest