5 ms·
Filesystems and memory allocation algorithms do have something in common. The problem of allocating memory and managing free space etc exists also without GC.
by ithkuil 14y ago
Filesystems and memory allocation algorithms do have something in common.
The problem of allocating memory and managing free space etc exists also without GC.
When hierarchical filesystems behave as pure trees, it's always possible to simply deallocate the storage of a deleted file, because the file cannot be pointed by more than one entry in the tree.
Unix filesystems, however, do have a way of creating several references to the same file, namely hard links. In order to handle these multiple references (like having a program with multiple variables pointing to the same object) a kind of GC algorithm is used, which is simply a "reference counting GC".
Reference counting is a simple technique which is appropriate in several cases but has it's drawbacks and it's
One of these drawbacks can be illustrated by this quote:
"One day a student came to Moon and said: “I understand how to make a better garbage collector. We must keep a reference count of the pointers to each cons.”
Moon patiently told the student the following story:
“One day a student came to Moon and said: ‘I understand how to make a better garbage collector... ”"
- caf 14y agoThis drawback is why sensible UNIX filesystems don't allow you to create hardlinks to directories.