lua-users home
lua-l archive

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


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()
> >
> 
> yes
> 
> >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.