Ad Space — Top Banner

?OUT OF MEMORY ERROR

Commodore VIC-20

Severity: Moderate

What Does This Error Mean?

?OUT OF MEMORY ERROR on the VIC-20 means your program has used all available RAM. The VIC-20 has only 5KB of total RAM, with just 3.5KB free for BASIC programs — the smallest of any popular home computer. You need to shorten your program, remove REMs, or add a RAM expansion cartridge.

Affected Models

  • Commodore VIC-20
  • Commodore VIC-20CR
  • VICE emulator (VIC-20)

Common Causes

  • Program too large for the 3.5KB of free BASIC RAM
  • Arrays or string variables consuming the tiny available memory
  • REM statements and long variable names wasting precious bytes
  • Deeply nested FOR-NEXT loops or GOSUB calls exhausting the stack
  • No RAM expansion cartridge installed

How to Fix It

  1. Type PRINT FRE(0) to check available free memory.

    On an unexpanded VIC-20, FRE(0) shows about 3583 bytes free. With an 8KB expansion: about 11583 bytes. With 16KB: about 19583 bytes. If the number is very small, your program is at the limit.

  2. Remove ALL REM statements — every byte counts on the VIC-20.

    On a machine with only 3.5KB, a few REM lines can make the difference between a program that runs and one that does not. Keep your comments on paper instead.

  3. Use single-letter variable names and abbreviate where possible.

    A=1 uses less memory than SCORE=1. Combine short lines with colons: 10 A=1:B=2:C=3 uses less memory than three separate lines.

  4. Add a RAM expansion cartridge.

    Commodore sold 3KB, 8KB, and 16KB RAM expansion cartridges for the VIC-20. With 16KB extra, you have over 19KB for BASIC — enough for substantial programs. In VICE emulator, go to Settings > VIC-20 settings > Memory expansions.

  5. Consider using machine language for parts of your program.

    Machine code is far more memory-efficient than BASIC. Many VIC-20 programs used a small BASIC loader that POKEd machine code into memory, then executed it with SYS.

Frequently Asked Questions

Why does the VIC-20 have so little memory?

The VIC-20 launched in 1981 at a price of just $299 (later $99). To hit that low price, Commodore used only 5KB of RAM. After the BASIC interpreter, screen memory, and system variables take their share, only 3583 bytes remain for programs.

How does the VIC-20's memory compare to the Commodore 64?

The C64 has 64KB total with about 38KB free for BASIC — roughly 10 times more than the unexpanded VIC-20. This is why many VIC-20 programs required RAM expansion cartridges to run.