| View previous topic :: View next topic |
| Author |
Message |
matriculated
Joined: 04 Mar 2006 Posts: 31
|
Posted: Sun Mar 25, 2007 2:07 pm Post subject: what happens to a image passed back from a function? |
|
|
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? |
|
| Back to top |
|
 |
romero126
Joined: 24 Dec 2005 Posts: 200
|
Posted: Mon Mar 26, 2007 6:20 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
matriculated
Joined: 04 Mar 2006 Posts: 31
|
Posted: Mon Mar 26, 2007 8:54 am Post subject: |
|
|
| Thanks for clearing that up! |
|
| Back to top |
|
 |
|