Housekeeping (computing)

In computer programming, housekeeping can refer to either a standard entry or exit routine appended to a user-written block of code (such as a subroutine or function, sometimes as a function prologue and epilogue) at its entry and exit or to any other automated or manual software process whereby a computer is cleaned up after usage (e.g. freeing resources such as virtual memory). This might include such activities as removing or archiving logs that the system has made as a result of the users activities, or deletion of temporary files which may otherwise simply take up space. Housekeeping can be described as a necessary chore, required to perform a particular computer's normal activity but not necessarily part of the algorithm. For cleaning up computer disk storage, utility software usually exists for this purpose such as data compression software - to "shrink" files and release disk space and defragmentation programs - to improve disk performance.

Examples
Housekeeping could include (but is not limited to) the following activities:
 * Saving and restoring program state for called functions (including general purpose registers and return address)
 * Obtaining local memory on the stack
 * Initializing local variables at the start of a program or function
 * Freeing local memory on the stack on exit from a function
 * Garbage collection
 * Data conversion
 * Backup and/or removal of un-needed files and software
 * Execution of disk maintenance utilities (e.g. ScanDisk, hard drive defragmenters, virus scanners)