Temporary file

From Wikipedia, the free encyclopedia

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 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. 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.

[edit] Usage

The usual filename extension for temporary files is ".TMP". Temporary files are normally created in a designated temporary directory reserved for the creation of temporary files.

On Unix, temporary files can be safely created with the mkstemp(3) library function, or with the mktemp(1) program. These files are typically located in the /tmp directory.

[edit] See also