Crashing when using large arrays

star_7
Posts: 3
Joined: Sat Dec 10, 2016 3:28 pm

Crashing when using large arrays

Postby star_7 » Wed Dec 21, 2016 8:44 am

My program always crash when using large arrays(100*1024),serial Prompt information:

Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception)
Register dump:
PC : 00000000 PS : 00000000 A0 : 00000000 A1 : 8007838d
A2 : 3ffe3c60 A3 : 50000008 A4 : 3ff0005c A5 : 00000000
A6 : 00000009 A7 : 00020010 A8 : 80078506 A9 : 00030000
A10 : 3ffe5650 A11 : 3ffe5650 A12 : 00000000 A13 : 80078506
A14 : 3ffe3ca0 A15 : 40080a2c SAR : 000008e

What's the problem?

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Crashing when using large arrays

Postby ESP_Angus » Thu Dec 22, 2016 12:48 am

Hi star_7,

Please post new topics when asking a new question, rather than replying to unrelated topic. I've split your post into a new topic.

If your array is allocated on the stack, you will need to make sure your task has a large enough stack. The third parameter to xTaskCreate() specifies the stack size.

If your array is allocated in heap with malloc(), you should test for a NULL result. For some large arrays, malloc() may fail if there is not enough contiguous memory available. It sounds like you are allocating on the stack, though.

Angus

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Crashing when using large arrays

Postby kolban » Thu Dec 22, 2016 1:21 am

To add a little to what Angus said ... I like to also use the esp_get_free_heap() function which returns the current amount of free heap storage. You can't dynamically allocate more free space than what is available as returned by that function.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: cdollar, joglz8 and 169 guests