Error 050
BBC Micro:bit
Severity: CriticalWhat Does This Error Mean?
Error 050 on the Micro:bit means the heap memory is corrupted or exhausted. The heap is where dynamically allocated objects (strings, arrays, objects) are stored. Simplify your program, reduce dynamic allocations, or use the V2 which has more memory.
Affected Models
- BBC Micro:bit V1
- BBC Micro:bit V2
Common Causes
- Creating too many dynamic objects (strings, arrays) that fragment the heap
- Memory leak — objects created but never freed
- Stack overflow corrupting the heap boundary
- Bug in a C++ extension corrupting memory
- Micro:bit V1 running a program too complex for its 16KB RAM
How to Fix It
-
Simplify your program — reduce string and array usage.
Every string and array allocation uses heap memory. Reuse variables instead of creating new ones. Avoid string concatenation in loops.
-
In MicroPython: use gc.collect() periodically.
import gc then gc.collect() frees unused objects. Call it periodically in long-running programs.
-
In MakeCode: avoid creating objects inside forever loops.
Creating new strings or arrays inside a forever block leaks memory. Create them once outside the loop and reuse.
-
Upgrade to Micro:bit V2 if possible.
V2 has 128KB RAM — 8x more than V1. Programs that crash with 050 on V1 usually work fine on V2.
Frequently Asked Questions
What is the difference between Error 020 and Error 050?
Error 020 means general out of memory — the program is too large. Error 050 means heap corruption — dynamic memory management has failed. 050 is often harder to fix because it involves how memory is used, not just how much.
What is the heap?
The heap is a region of memory used for dynamically allocated data — things created while the program runs (like strings and arrays). It is separate from the stack (which tracks function calls) and the program code area.