Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

heap_caps_malloc vs new class #11305

Unanswered
bhcuong2008 asked this question in Q&A
Discussion options

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?

You must be logged in to vote

Replies: 1 comment

Comment options

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

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /