lua-users home
lua-l archive

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

On Mon, Jan 16, 2006 at 12:47:53PM +0800, CHU Run-min wrote:
> Thanks, I understand it.
> But lua-5.1 manual seems confusing me. It says
> "Finalizers allow you to coordinate Lua's garbage collection with
> external resource management (such as closing files, network or
> database connections, or freeing your own memory). "
For the most part this should be viewed as a desperate measure
of last resort only.

However, in some environments it might work out well.
Consider a process serving several requests sequentially,
each with it's own environment which is dropped afterwards
followed by a forced full gc.
You might get a behaviour similar to PHP,
i.e. lazy scripting works most of the time.

More generally it might be useful after catching an error,
which might mean some open ressources got lost on the way up.
Since programming in the try-catch-finally style on every call
level is slow, tedious and error prone, you might consider
doing a full gc after catching on some outer level.