guile-devel
[Top][All Lists]
Advanced

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

Re: documentation.scm close files


From: Kevin Ryde
Subject: Re: documentation.scm close files
Date: Sat, 24 May 2003 11:50:24 +1000
User-agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux)

address@hidden writes:
>
> it seems important to me to make even clearer that the garbage collector
> is triggered when we are short on memory

Yep, good point.  New words below.

> ``the system will trigger the garbage collector based on memory
> usage, but it won't notice if it is running low on file descriptors,

I guess some sort of file descriptor threshold scheme might be cute.
Like garbage collect after every 10 or 20 files net opened (ie. opens
less explicit closes).

I suppose to be reliable such a scheme would need to be carefully
applied to all functions opening or closing fds.  Not much value if
it's not universal.



   It is strongly recommended that file ports be explicitly closed when
no longer required.  Most systems have limits on how many files can be
open, both on a per-process and a system-wide basis.  A program that
uses many files should take care not to hit those limits.  The same
applies to similar system resources such as pipes and sockets.

   Note that automatic garbage collection is triggered only by memory
consumption, not by file or other resource usage, so a program cannot
rely on that to keep it away from system limits.  There would be little
value in Guile attempting this, since the consequences of even
approaching limits tend to be serious both for a program's own
operation (eg. libraries accessing files), and for other processes (eg.
jobs failing intermittently).

   An explicit call to `gc' can of course be relied on to pick up
unreferenced ports.  If program flow makes it hard to be certain when
to close then this may be an acceptable way to control resource usage.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]