[plt-scheme] ports and garbage collection
At Sat, 20 Nov 2004 19:13:47 -0500, Doug Orleans wrote:
> I thought ports were closed when garbage collected, but apparently
> not. How come?
One reason is that file and network connections are relatively scarce,
often limited to 1024 or so total. That's scarce enough that
conservative GC isn't a reliable way to manage them. (Maybe a precise
GC overcomes this problem, but I have doubts.)
The more compelling reason is that closing a port is not always an
atomic operation. In particular, there can be an error when closing a
port, and it makes no sense for the GC to raise a port-close error. (A
port can be aborted atomically, which is what a custodian shutdown
does, but that's not a normal close.)
Matthew