ComputerCraft

ComputerCraft

21M Downloads

Automatically Close File Handles

Restioson opened this issue ยท 3 comments

commented

In release 1.8.9, if you do not close a file handle, or terminate the program before it has closed the handle, you cannot edit the file. It would be nice it was closed when the program which owns the handle is terminated.

commented

Could even be done with Object.finalize, but we don't talk about that.

commented

I'd rather people just closed file handles, but I realise bugs happen :). Instead of closing it when the program terminates (which isn't really feasible), it would probably be better to close it when the handle is garbage collected. This could probably be done with a ReferenceQueue and a weak reference to the IMountedFile.

commented

This should be fixed in 09215da
Previously, that HashSet was preventing the java GC from collecting lost file handles.