I have a function that returns an image. But what happens if I don't assign it to anything - like this:
screen:blit(0, 0, gradient(480, 16, white, black))
Where the function, gradient, creates an image of width 480 and height 16 with a color gradient going from white to black. So what happens to the results of the function? Does it get disposed of immediately?
what happens to a image passed back from a function?
Moderators: Shine, Insert_witty_name
-
- Posts: 31
- Joined: Sat Mar 04, 2006 1:35 am
With the collect garbage function Theortically is disposed of within a certain ammount of time. Which is about 30sec to 1 min. Which means the image returned is still taking a chunk of the memory for a while.
Results of functions act exactly like variables that are set and then immediatly set to nil after use.
Example
Check memory
load an image..
Display that image
Remove that image
Check Memory
The loaded image is still loaded into memory by checking the memory in the ram. It will not be cleared until the garbage collection is used.
Results of functions act exactly like variables that are set and then immediatly set to nil after use.
Example
Check memory
load an image..
Display that image
Remove that image
Check Memory
The loaded image is still loaded into memory by checking the memory in the ram. It will not be cleared until the garbage collection is used.