This article was previously published under Q103237
This article has been archived. It is offered "as is" and will no longer be updated.
If you use temporary files, you can significantly increase the performanceof your application.
By using CreateFile() with the FILE_ATTRIBUTE_TEMPORARY flag, you let thesystem know that the file is likely to be short lived. The temporary fileis created as a normal file. The system needs to do a minimal amount oflazy writes to the file system to keep the disk structures (directories andso forth) consistent. This gives the appearance that the file has beenwritten to the disk. However, unless the Memory Manager detects aninadequate supply of free pages and starts writing modified pages to thedisk, the Cache Manager's Lazy Writer may never write the data pages ofthis file to the disk. If the system has enough memory, the pages mayremain in memory for any arbitrary amount of time. Because temporary filesare generally short lived, there is a good chance the system will neverwrite the pages to the disk.
To further increase performance, your application might mark the file asFILE_FLAG_DELETE_ON_CLOSE. This indicates to the system that when the lasthandle of the file is closed, it will be deleted. Although the systemgenerally purges the cache to ensure that a file being closed is updatedappropriately, because a file marked with this flag won't exist after theclose, the system foregoes the cache purge.