[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua Basics: file opens and the colon?
- From: Klaus Ripke <paul-lua@...>
- Date: Mon, 29 Aug 2005 22:47:20 +0200
On Mon, Aug 29, 2005 at 03:18:48PM -0500, Rici Lake wrote:
> On 29-Aug-05, at 2:51 PM, William Trenker wrote:
> >Is the following an acceptable use of the colon with io functions?
> >kernelinfo = io.open("/proc/version"):read()
> >machinetype = io.popen("uname -m"):read()
> >I just want to be sure that this won't leave a file handle or related
> >resources dangling.
> The garbage collector will deal with it eventually, which is probably
> good enough.
.. for one-shot-scripts, yes.
For a long running app, you should always control your ressource
usage at least by forcing a full gc run every request or some.
examples where lazy file closing blows up quite quickly
include scanning maildirs etc.