-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Board
ESP32 DEV MOUDLE
Device Description
In the arduino environment, I can't seem to request more than 120k bytes of memory space using the malloc function, either using the malloc
function, the heap_caps_malloc
function or the c++ style new
keyword. And trying to request more memory with the new
keyword will cause the whole system to crash and reboot. But when I tested in esp idf environment, I didn't find this problem
Hardware Configuration
The development board is not connected to any peripheral
Version
latest master (checkout manually)
IDE Name
PlatformIO and Arduino IDE
Operating System
Windows11
Flash frequency
80Mhz
PSRAM enabled
no
Upload speed
921600
Description
I want to be able to request more than 120k of memory on the arduino platform, but I can't do it with malloc
and heap_caps_malloc
, and using the new keyword causes the system to crash and reboot. And this is perfectly supported on the esp idf.
Sketch
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
log_i("before malloc,free heap:%.1fkb", (float)esp_get_free_heap_size() / 1024.0);
void *ptr = malloc(120 * 1024);
if (ptr == nullptr)
{
log_i("malloc failed");
}
else
{
log_i("after malloc,free heap:%.1fkb", (float)esp_get_free_heap_size() / 1024.0);
heap_caps_print_heap_info(MALLOC_CAP_INTERNAL);
}
void *ptr2 = heap_caps_malloc(120 * 1024,MALLOC_CAP_8BIT);
if (ptr2 == nullptr)
{
log_i("malloc failed");
}
else
{
log_i("after malloc,free heap:%.1fkb", (float)esp_get_free_heap_size() / 1024.0);
heap_caps_print_heap_info(MALLOC_CAP_INTERNAL);
}
uint8_t *ptr3 = new uint8_t[120 * 1024];
if (ptr3 == nullptr)
{
log_i("malloc failed");
}
else
{
log_i("after malloc,free heap:%.1fkb", (float)esp_get_free_heap_size() / 1024.0);
heap_caps_print_heap_info(MALLOC_CAP_INTERNAL);
}
}
void loop()
{
}
Debug Message
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13516
load:0x40080400,len:3604
entry 0x400805f0
[
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.