pxt-calliope/olddocs/js/object-disclaimer.md

26 lines
518 B
Markdown
Raw Permalink Normal View History

2016-03-26 00:47:20 +01:00
# Objects disclaimer
2016-11-02 01:44:37 +01:00
Touch Develop docs for the @boardname@.
2016-03-26 00:47:20 +01:00
### Memory management on the micro-bit
New user-defined object types are allocated on the heap and are ref-counted. Our ref-counting algorithm does *not* have a cycle collector. (See Wikipedia.)
### Practical consequences
This means that the following script will result in an out-of-memory error.
![](/static/mb/object-disclaimer-0.png)
```
while (true) {
let l = new List()
l.next = l
}
```
### How to avoid this?
Don't do it. It's bad.