[Haskell-cafe] Are handles garbage-collected?

Remi Turk rturk at science.uva.nl
Mon Oct 25 14:26:02 EDT 2004

On Mon, Oct 25, 2004 at 08:46:41AM +0200, Ketil Malde wrote:
> Remi Turk <rturk at science.uva.nl> writes:
> > IMO, [bracket] does indeed have those same drawbacks. (Although the
> > traditional "explicit memory management model" is alloc/free,
> > which is much worse than bracket/withFile)
> Isn't bracket more like stack allocated memory?  And most problems
> with explicit memory management related to heap (as you indicate)?

I think you're right. (WRT usage (only): AFAICS even
Foreign.Marshal.Alloc.alloca doesn't actually use the stack.)

> > The theoretical solution (and probably _only_ theoretical) is
> > implementing a lot of garbage collectors: one for memory, one for
> > open files, one for sockets, one for 3D polygon meshes etc etc...
> ...or have a number of available file handles that is limited by
> memory? :-)

Would be nice if OSes actually worked that way.
Then again, I don't think _everything_ can be made dependent only
on available memory.


Nobody can be exactly like me. Even I have trouble doing it.

More information about the Haskell-Cafe mailing list