Memory Leak

One of the most frequently tossed around phrases in the TI-Basic community is memory leaks, but what is a memory leak, and why are they so important? Simply put, a memory leak is where you use a Goto/Lbl within a loop or If conditional (anything that has an End command) to jump out of that control structure before the End command is reached:

:Lbl A
:While 1
:Goto A

This in itself wouldn't necessarily be a bad thing, except that the calculator stores all of the End commands on its built-in operator stack. Each End command takes up a little bit of memory (like a dozen bytes or so), and when the calculator reaches the End command for the associated loop/conditional, it not only removes it from the stack, but also returns that memory back to the calculator.

However, if you jump out of a control structure, you never allow the calculator to remove the End from the stack, and it subsequently keeps the memory. Since the operator stack is stored in RAM, each additional memory leak further depletes the calculator's memory, until you eventually reach the point where the calculator runs out of memory (giving you the dreaded ERR:MEMORY error).

Most people would probably not have a problem with this, and still use memory leaks just with some caution, but there is one important caveat of memory leaks: the program will gradually slow down over time. This problem is actually caused by TI's faulty programming, where the calculator loses track of some of the bytes associated with the End command in the operator stack.

It should be noted that this problem only afflicts the TI-83 series of graphing calculators; 68k TI-Basic loops have offsets linking the end to the beginning, so the program doesn't need to keep a stack to be aware of what to do with End instructions.