-
Couldn't load subscription status.
- Fork 7.7k
heap_caps_malloc vs new class #11305
-
Hi,
ESP-IDF provides heap_caps_malloc to allocate memory with specific flags. But how about construct an object with new keyword. For example,
Person *p = new Person();
How do we specify allocating the object Person in PSRAM or in IRAM?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
ESP32 Arduino has set the IDF parameter to use malloc() for new operator.
It will use HEAP (DRAM) when the size of the allocated data space is lower than 4KB, otherwise, it will allocate it from PSRAM, whenever it is enabled in the Arduino IDE Tools Menu.
sdkconfig settings:
CONFIG_SPIRAM_USE_MALLOC=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096
References:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-guides/external-ram.html#provide-external-ram-via-malloc
https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/kconfig-reference.html#config-spiram-malloc-alwaysinternal
Beta Was this translation helpful? Give feedback.