lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I forget what is the standard solution to make Lua's GC
aware of the external cost of a "userdata" value. Sometimes
you have a userdata representing, say, an image. But the
image itself takes more room than the userdata because it
was allocated outside of Lua (sometimes you can't change
that). So Lua might not feel like collecting the userdata
eventhough it represents a lot of memory and is not
referenced anymore.

Can anyone refresh my memory?

__gc

__gc will only be executed when the garbage collector feels
like it. This decision is based on how much memory the userdata itself takes (a few bytes). However, this userdata might be just a boxed pointer, pointing to a big hunk of external
memory (say, a few megabytes).

[]s,
Diego.