The Memory Wars — Life in a Zero-Sum World: TSR — The Terminate and Stay Residents

A TSR is a program that has learned the secret all programs fear: that termination need not be final.

In the conventional understanding of program execution under DOS, a program loads, runs, and exits. INT 21h, function 4Ch — terminate process. The memory is freed. The program is gone. This is the natural order: birth, purpose, death. But some programs refuse this order. They call INT 27h — Terminate and Stay Resident — or its more sophisticated cousin, INT 21h function 31h, and something unprecedented occurs: the program ends its active execution but does not release its memory. It remains. It persists. It has installed itself in the interrupt vector table, hooking one or more interrupt handlers, and now it waits — invisible to the user, invisible to other programs, consuming memory like a ghost consuming air, which is to say: undeniably, but in a way that is difficult to measure and impossible to see. The canonical TSRs are well-known. DOSKEY.COM hooks INT 21h to provide command-line history and macro expansion — a convenience so fundamental that its 4K memory cost is accepted witho...

From the lore of Conventional Memory.