2016-10-13 09:32:34 -04:00
|
|
|
# check that heap_lock/heap_unlock work as expected
|
|
|
|
|
|
|
|
import micropython
|
|
|
|
|
2018-03-01 18:59:09 -05:00
|
|
|
l = []
|
|
|
|
l2 = list(range(100))
|
|
|
|
|
2016-10-13 09:32:34 -04:00
|
|
|
micropython.heap_lock()
|
|
|
|
|
2018-03-01 18:59:09 -05:00
|
|
|
# general allocation on the heap
|
2016-10-13 09:32:34 -04:00
|
|
|
try:
|
|
|
|
print([])
|
|
|
|
except MemoryError:
|
|
|
|
print('MemoryError')
|
|
|
|
|
2018-03-01 18:59:09 -05:00
|
|
|
# expansion of a heap block
|
|
|
|
try:
|
|
|
|
l.extend(l2)
|
|
|
|
except MemoryError:
|
|
|
|
print('MemoryError')
|
|
|
|
|
2016-10-13 09:32:34 -04:00
|
|
|
micropython.heap_unlock()
|
|
|
|
|
2018-03-01 18:59:09 -05:00
|
|
|
# check that allocation works after an unlock
|
2016-10-13 09:32:34 -04:00
|
|
|
print([])
|