in reply to Re: Why do we need to close filehandles?
in thread Why do we need to close filehandles?

As a complete “aside point,” I normally do not ask my applications to “flush buffered data to disc.”   If you want to see just how badly this can affect performance (albeit with a perfectly good reason in this case), try using an SQLite database without using transactions.   Just let the data sit in the operating-system buffers as it normally does, and basically just let the OS do its thing.   But, when you have reached a logical end-point in whatever it is that you are doing, explicitly inform the operating system that you have done so, by closing the file.

Writes to things like flash-cards can be astonishingly slow, continuing for many seconds after the application has closed.   That is why it is paramount to drill-in to your users that they must dismount the cards, and wait for that process to finish, before removing the cards from the USB port.   (You’ve got maybe a 50% chance that your grandmother will actually listen to you, but maybe that’s better than nothing.)

Replies are listed 'Best First'.
Re^3: Why do we need to close filehandles?
by Anonymous Monk on May 01, 2011 at 20:58 UTC

    Or wait for the light on the device to change state, like an old school floppy drive.

    But that's not 100% guaranteed.