why can't I use an array of size larger than 3584 bytes in main() ?
Posted: Fri Jun 02, 2023 12:03 am
In the following code, I declared an array of size 3585 bytes, it compiles without error but during execution, it constantly reboots my esp32-Wrover-E chip. If I reduce the array size to 3584 bytes, then there is no such issue. Why?
Also, if I declare the array of size larger than 3585 bytes outside the main() or use malloc, there is no issue.
PS: I am using esp-idf 5.0.1 stable
Also, if I declare the array of size larger than 3585 bytes outside the main() or use malloc, there is no issue.
PS: I am using esp-idf 5.0.1 stable
Code: main.c Select all
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <stdio.h>
void app_main(void)
{
uint8_t int_array[3585] = {0};
while (1)
{
int_array[0]++;
array[0]++;
printf("static array size: %d, count: %d\n", (unsigned int)sizeof(int_array), (unsigned int)int_array[0]);
vTaskDelay(pdMS_TO_TICKS(1000));
}
}