From 28b5b293b5a825eb1ec6232386bb5c4daf445d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Moskal?= Date: Mon, 1 Jul 2019 18:39:12 -0700 Subject: [PATCH] Use gcPreAllocateBlock() to fix #2177, #2215 (#2216) * Use gcPreAllocateBlock() to fix #2177, #2215 * bump pcp 6.9.4 --- libs/core/codal.cpp | 6 +++++- libs/core/pxtcore.h | 2 ++ package.json | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libs/core/codal.cpp b/libs/core/codal.cpp index 05f36878..1c4b4894 100644 --- a/libs/core/codal.cpp +++ b/libs/core/codal.cpp @@ -18,14 +18,18 @@ extern "C" void target_reset() { microbit_reset(); } +uint32_t device_heap_size(uint8_t heap_index); // defined in microbit-dal + namespace pxt { MicroBit uBit; MicroBitEvent lastEvent; void platform_init() { - microbit_seed_random(); + microbit_seed_random(); seedRandom(microbit_random(0x7fffffff)); + if (device_heap_size(1)) + gcPreAllocateBlock(device_heap_size(1) - 4); } void platform_init(); diff --git a/libs/core/pxtcore.h b/libs/core/pxtcore.h index 51d0dab7..abd5d0b8 100644 --- a/libs/core/pxtcore.h +++ b/libs/core/pxtcore.h @@ -14,6 +14,8 @@ void debuglog(const char *format, ...); #define xmalloc malloc #define xfree free +#define GC_MAX_ALLOC_SIZE 9000 + #if CONFIG_ENABLED(MICROBIT_BLE_ENABLED) #define GC_BLOCK_SIZE 256 #else diff --git a/package.json b/package.json index 2268bbaa..3e696f22 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@types/web-bluetooth": "0.0.4" }, "dependencies": { - "pxt-common-packages": "6.9.3", + "pxt-common-packages": "6.9.4", "pxt-core": "5.15.10" } -} +} \ No newline at end of file