lua-users home
lua-l archive

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


On Tue, Feb 4, 2014 at 4:56 PM, Tim Hill <drtimhill@gmail.com> wrote:

On Feb 4, 2014, at 1:42 PM, Paul K <paulclinger@yahoo.com> wrote:

> The documentation for Lua 5.2 says about the second parameter:
>
>> If the optional second argument close is true, closes the Lua state before exiting.
>
> Can someone comment on why it may be needed? The difference comes to
> lua_close(L) call, but what are the implications in terms of garbage
> collections/memory use when the Lua state is not closed? I thought
> os.exit would terminate the host program, so why was the second
> parameter introduced?
>
> Paul.
>

The biggest difference is that __gc metamethods will get called, allowing the app to cleanup resources (flush to disk, close files etc etc). There is no difference to dangling memory since the OS will clean all that up anyway when the process exits (it will close files too, but user-level buffers may not be flushed).

—Tim



I wonder why you'd want the state to *not* be shut down, let alone for that to be the default?

--
Sent from my Game Boy.