Temporary file
| This article does not cite any references or sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (April 2011) |
Temporary files may be created by computer programs for a variety of purposes; principally when a program cannot allocate enough memory for its tasks, when the program is working on data bigger than the architecture's address space, or as a primitive form of inter-process communication.
Contents |
[edit] Auxiliary memory
Modern operating systems employ virtual memory, however programs that use large amounts of data (e.g. video editing) may need to create temporary files.
[edit] Inter-process communication
Most operating systems offer primitives such as pipes, sockets or shared memory to pass data among programs, but often the simplest way (especially for programs that follow the Unix philosophy) is to write data into a temporary file and inform the receiving program of the location of the temporary file.
[edit] Cleanup
Some programs create temporary files and then leave them behind - they do not delete them. This can happen because the program crashed or the developer of the program simply forgot to add the code needed to delete the temporary files after the program is done with them (disk leak). In Microsoft Windows the temporary files left behind by the programs accumulate over time and can take up a lot of disk space. System utilities, called temporary file cleaners or disk cleaners, can be used to address this issue. Personal workstations with UNIX-based operating systems do not suffer from the same problem because their temporary files are wiped at boot. Servers, however, are affected because they are rarely rebooted.
[edit] Usage
On POSIX systems, temporary files can be safely created with the or library functions, or with the program. These files are typically located in the standard temporary directory, /tmp on Unix machines or %TEMP% (which is log-in specific) on Windows machines.
Usually a temporary file is deleted automatically when the program exits or the file is closed. To generate a temporary file name that will survive past the lifespan of the creating program, or GetTempFileName(...) (Windows only) can be used.
[edit] See also
| This computer storage-related article is a stub. You can help Wikipedia by expanding it. |