In some places the IO library simply assumes that the IO request is 'small enough', and happily allocates a buffer big enough for the request to be handled in one go. Unformatted IO already uses sread()/swrite() which bypasses buffering if the request is bigger than the buffer size. However, this has not been done for formatted IO. In some cases this results in excessive memory usage. A rather extreme (and admittedly contrived) example is
program bigformdir integer :: i = 10**9 open (10, file="foo", form="formatted", access="direct", recl=i) write (10, '(i3)', rec=1) 1 close (10) end program bigformdir The above program will cause libgfortran to allocate 1 GB, fill it with ' ', and then write it. Clearly the allocation is not necessary. -- Summary: Unbounded I/O buffer memory usage for formatted IO Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: libfortran AssignedTo: jb at gcc dot gnu dot org ReportedBy: jb at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25949