The Arduino Nano 33 BLE uses mbedOS and bare metal approach will likely not work. Maybe the following page helps answer your questions.

https://os.mbed.com/blog/entry/Tracking-memory-usage-with-Mbed-OS/

This works like a charm. Thanks!

A slightly improved function for Arduino:

`void print_memory_info(char* printEvent, int iSize) {`

// allocate enough room for every thread's stack statistics

int cnt = osThreadGetCount();

mbed_stats_stack_t *stats = (mbed_stats_stack_t*) malloc(cnt * sizeof(mbed_stats_stack_t));

cnt = mbed_stats_stack_get_each(stats, cnt);

for (int i = 0; i < cnt; i++) {

snprintf_P(printEvent, iSize, "Thread: 0x%lX, Stack size: %lu / %lu\r\n", stats[i].thread_id, stats[i].max_size, stats[i].reserved_size);

Serial.println(printEvent);

}

free(stats);

// Grab the heap statistics

mbed_stats_heap_t heap_stats;

mbed_stats_heap_get(&heap_stats);

snprintf_P(printEvent, iSize, "Heap size: %lu / %lu bytes\r\n", heap_stats.current_size, heap_stats.reserved_size);

Serial.println(printEvent);

}