Thursday, April 22, 2004

It's only temporary (“temporary” temporary files.)

It's only temporary

"NT has a whole lot of really cool features that aren’t always obvious without REALLY looking closely at the documentation.

One of my favorite is what I call “temporary” temporary files.

A “temporary” temporary file is one whose storage is never written to disk (in the absence of memory pressure). It behaves just like a file does (because it’s a file) but the cache manager disables the lazy writer on the file, and the filesystem knows to never commit the pages containing the file’s metadata to disk.

To create a “temporary” file, you call CreateFile specifying FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE in the dwFlagsAndAttributes attribute. This combination of bits acts as a hint to the filesystem that the file data and metadata should never be flushed to disk. In other words, such a file can be created, written to, and read from without the system ever touching the disk."

Cool... Again, something I know I'll need one day...

No comments: