If one has *many* opened streams (which is possible if the max number of opened file descriptors per process has been tuned beyond the typical 1024), fclose() starts being *very* slow. The root cause is the following linear search in genops.c/_IO_un_link: d18ea0c5 68 for (f = &_IO_list_all->file._chain; *f; f = &(*f)->_chain) 9964a145 69 if (*f == (FILE *) fp) 40a55d20 70 { cedb4109 71 *f = fp->file._chain; 40a55d20 72 break; UD 73 } Clearly a singly-linked list does not allow for O(1) removal. Given what I understand of the design constraints of this list, the most natural fix would be to switch to a doubly-linked list.