Release resource

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Blady
Prole
Posts: 4
Joined: Sat Nov 20, 2010 10:08 am

Release resource

Post by Blady »

Hi

I have simple question. How to release a resource?

My idea is:

Code: Select all

image = love.graphics.newImage("some_nice_image.jpg")
...
image = nil
It's good? I think, it doesn't release a memory.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Release resource

Post by Robin »

Pretty much. As soon as there is no reference left to an object, it is availably for the garbage collector to release it. You don't have to worry about this most of the time, though.
Help us help you: attach a .love.
Blady
Prole
Posts: 4
Joined: Sat Nov 20, 2010 10:08 am

Re: Release resource

Post by Blady »

But when My program have a structure like that:

Code: Select all

Game have a modules:
1.Menu
2.Game

When Menu has left for a Game module, Menu resources need to be free.
Something like that. shouldn't I take care about Menu resources? and for others any modules that I will have?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Release resource

Post by Robin »

I doubt it.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests