what happens to a image passed back from a function?

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
matriculated
Posts: 31
Joined: Sat Mar 04, 2006 1:35 am

what happens to a image passed back from a function?

Post by matriculated »

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?
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

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.
matriculated
Posts: 31
Joined: Sat Mar 04, 2006 1:35 am

Post by matriculated »

Thanks for clearing that up!
Post Reply