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 progra ...
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 In computing, an address space defines a range of discrete addresses, each of which may correspond to a network host, peripheral device, disk sector, a memory cell or other logical or physical entity. For software programs to save and retrieve ...
, 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 daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
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-circul ...
, 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 d ...
) 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 inte ...
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 inte ...
(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, (the fifth overall), from the 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 stations, along with some Alternativ ...
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 stora ...
, inherently do not preserve files across a reboot.


See also

* Temp File Cleaner * Temporary folder * Temporary filesystem *
Temporary variable In computer programming, a temporary variable is a variable with short lifetime, usually to hold data that will soon be discarded, or before it can be placed at a more permanent memory location. Because it is short-lived, it is usually declared as ...


References

{{Computer files Computer file systems