Somebody wondered how Photoshop manages to create a 2GB temporary file immediately upon startup with virtually none of the disk thrashing one would expect from writing out gigabytes. The Windows function for doing that is SetEndOfFile, which sets the length of the file to the current position. That function updates the file metadata with the new length and commits the physical space on the disk, but the space is not zeroed out until data is written beyond the valid data length (which is not changed by this function).
For paging-esque storage, this method is to be preferred over sparse files, which do not commit the space ahead of time and therefore could produce out-of-disk-space errors in the middle of something important.
No comments:
Post a Comment