HOME

TheInfoList



OR:

A temporary file is a file created to store information temporarily, either for a program's intermediate use or for transfer to a permanent file when complete. It may be created by
computer program A computer program is a sequence or set of instructions in a programming language for a computer to execute. Computer programs are one component of software, which also includes documentation and other intangible components. A computer program ...
s for a variety of purposes, such as 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.


Auxiliary memory

Modern
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also i ...
s employ
virtual memory In computing, virtual memory, or virtual storage is a memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "creates the illusion to users of a very ...
, however programs that use large amounts of data (e.g.
video editing Video editing is the manipulation and arrangement of video shots. Video editing is used to structure and present all video information, including films and television shows, video advertisements and video essays. Video editing has been dramatical ...
) may need to create temporary file(s).


Inter-process communication

Most operating systems offer primitives such as
pipes Pipe(s), PIPE(S) or piping may refer to: Objects * Pipe (fluid conveyance), a hollow cylinder following certain dimension rules ** Piping, the use of pipes in industry * Smoking pipe ** Tobacco pipe * Half-pipe and quarter pipe, semi-circula ...
, sockets or
shared memory In computer science, shared memory is memory that may be simultaneously accessed by multiple programs with an intent to provide communication among them or avoid redundant copies. Shared memory is an efficient means of passing data between progr ...
to pass data among programs, but often the simplest way (especially for programs that follow the
Unix philosophy The Unix philosophy, originated by Ken Thompson, is a set of cultural norms and philosophical approaches to minimalist, modular software development. It is based on the experience of leading developers of the Unix operating system. Early Unix de ...
) is to write data into a temporary file and inform the receiving program of the location of the temporary file.


Creation

Operating systems and programming languages typically provide functions for obtaining unique temporary file names. On
POSIX The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming inter ...
systems, temporary files can be safely created with the mkstemp or library functions. Some systems provide the former
POSIX The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming inter ...
(now removed) 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. A temporary file created with 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, (POSIX) or GetTempFileName(...) (Windows) can be used.


Issues

Some programs create temporary files and then leave them behind - they do not delete them. This can happen because the program
crashed "Crashed" is the third U.S. rock Single (music), single, (the fifth overall), from the band Daughtry (band), Daughtry's debut album. It was released only to U.S. rock stations on September 5, 2007. Upon its release the song got adds at those stat ...
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 can accumulate over time and consume a lot of disk space. Temporary files may be deleted manually. Operating systems may clear out the temporary directory on a reboot, and they may have "cleaner" scripts that remove files if they have not been accessed in a certain amount of time. Also, memory-based filesystems, such as
tmpfs tmpfs (short for Temporary File System) is a temporary file storage paradigm implemented in many Unix-like operating systems. It is intended to appear as a mounted file system, but data is stored in volatile memory instead of a persistent storage ...
, inherently do not preserve files across a reboot.


See also

*
Temp File Cleaner Temp File Cleaner (TFC) is a utility program for Microsoft Windows designed to quickly remove temporary and unnecessary files which might otherwise prove difficult to find because of dynamic paths and multiple locations. Features TFC's minim ...
*
Temporary folder In computing, a temporary folder or temporary directory is a directory used to hold temporary files. Many operating systems and some software automatically delete the contents of this directory at bootup or at regular intervals, leaving the direct ...
*
Temporary filesystem tmpfs (short for Temporary File System) is a temporary file storage paradigm implemented in many Unix-like operating systems. It is intended to appear as a mounted file system, but data is stored in volatile memory instead of a persistent storage ...
* Temporary variable


References

{{Computer files Computer file systems