ofstream close hangs for large files

I'm running a single-threaded application on RHEL 6.1. This process uses a std::ofstream object to log incoming data to a file. Every 24 hours, the file is cycled. Specifically, close() is called on the stream for file1, following by open() with a new filename.

LFS is supported on the OS; however I ran into interesting behavior when dealing with a very large file (19.5 GB). The call to ofstream::close() took nearly 2 minutes to return. When dealing with files on the order of 8.5 GB or lower, I didn't see this issue and the close appeared to finish right away.

The workaround when dealing with this larger file is obviously to cycle it more often. But has anyone seen or dealt with this issue? Is there a threshold that we're crossing where the stream begins to struggle (for lack of a better term)?

Last edited on
Topic archived. No new replies allowed.