Hi, Eric Kow <[email protected]> writes: > And thanks for pointing that out. Also, sorry for being dense, but > could you explain to me explicitly the relationship between file > descriptors and garbage collection? I'm not really making the leap > here. Here. To mmap a region of a file, you need to first open that file in an appropriate way. That is, the mmap system call takes a filedescriptor, not a path. You can't close the file as long as the mapping is active -- which it is as long, as the returned bytestring value is active -- its finalizer will call munmap (which is triggered by the GC figuring that the object is no longer reachable).
To compound that problem, the GC perceives the bytestring object as occupying just a single pointer (maybe 4/8 bytes, dunno how big haskell pointers are... maybe twice the size for some tagging or metainformation, but still very small). So you can reasonably mmap thousands of files without GC noticing any need for cleaning up (there's no pressure on the heap). However, descriptors are running out, and if you force GC, their respective objects will be collected, maps unmappend and files closed => voila, free descriptors again... > Also, how did our old mmap code deal with this situation? Probably not at all. Yours, Petr. -- Peter Rockai | me()mornfall!net | prockai()redhat!com http://blog.mornfall.net | http://web.mornfall.net "In My Egotistical Opinion, most people's C programs should be indented six feet downward and covered with dirt." -- Blair P. Houghton on the subject of C program indentation _______________________________________________ darcs-users mailing list [email protected] http://lists.osuosl.org/mailman/listinfo/darcs-users
