[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: When to use os.exit(code, true)?
- From: Tim Hill <drtimhill@...>
- Date: Tue, 4 Feb 2014 13:56:22 -0800
On Feb 4, 2014, at 1:42 PM, Paul K <email@example.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?
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).