INFO: Using Temporary Files Can Improve Application Performance

Last reviewed: November 26, 1997
Article ID: Q103237
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with: - Microsoft Windows NT versions 3.1, 3.5, 3.51, 4.0

SUMMARY

If you use temporary files, you can significantly increase the performance of your application.

MORE INFORMATION

By using CreateFile() with the FILE_ATTRIBUTE_TEMPORARY flag, you let the system know that the file is likely to be short lived. The temporary file is created as a normal file. The system needs to do a minimal amount of lazy writes to the file system to keep the disk structures (directories and so forth) consistent. This gives the appearance that the file has been written to the disk. However, unless the Memory Manager detects an inadequate supply of free pages and starts writing modified pages to the disk, the Cache Manager's Lazy Writer may never write the data pages of this file to the disk. If the system has enough memory, the pages may remain in memory for any arbitrary amount of time. Because temporary files are generally short lived, there is a good chance the system will never write the pages to the disk.

To further increase performance, your application might mark the file as FILE_FLAG_DELETE_ON_CLOSE. This indicates to the system that when the last handle of the file is closed, it will be deleted. Although the system generally purges the cache to ensure that a file being closed is updated appropriately, because a file marked with this flag won't exist after the close, the system foregoes the cache purge.

Keywords          : BseFileio
Version           : winnt:3.1,3.5,3.51,4.0
Platform          : winnt
Issue type        : kbinfo


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 26, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.