Largest contiguous RAM for HEAP
Re: Largest contiguous RAM for HEAP
If you are going to use the IRAM memory there are limitation that you must be aware off. https://esp32.com/viewtopic.php?t=23891#p94825
Re: Largest contiguous RAM for HEAP
If you really don't want allocations to happen in a certain area, have you tried "reserving" it by doing the allocation before the other (smaller) allocations? If you need that space temporarily, you can still try to assign memory from the "reserved" space temporarily, effectively implementing your own memory management.
A really naive solution, but it might work.
A really naive solution, but it might work.
Re: Largest contiguous RAM for HEAP
This is what I have tried:ESP_jakob wrote: ↑Wed Oct 18, 2023 10:30 amIf you really don't want allocations to happen in a certain area, have you tried "reserving" it by doing the allocation before the other (smaller) allocations? If you need that space temporarily, you can still try to assign memory from the "reserved" space temporarily, effectively implementing your own memory management.
A really naive solution, but it might work.
- Reserve large block temporarly
- Do smaller things
- Free large block for large allocation
- Allocate large block (done unter the hood by std::make_unique<>())
- SOME RTOS/IDF RELATED DYNAMIC ALLOCATIONS MAY OCCUR?!?!
- Free large block (destroy unique_ptr object)
- SOME RTOS/IDF RELATED DYNAMIC ALLOCATIONS MAY OCCUR?!?!
- Try to reallocate the large block with std::make_unique<>() -> error large block is not available any more
It seems that whatever dynamic allocation stuff is going on in between, maybe from RTOS and/or IDF somehow shrinks the heap area which contains the large block so that eventually one can't allocate the large contiguous block anymore.
If one could tell malloc to allocate first from D/IRAM as priority, then maybe the large block (DRAM) stays untouched.
Hmm, not an easy one, I guess...
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Largest contiguous RAM for HEAP
https://docs.espressif.com/projects/esp ... ble-memory
-> "MALLOC_CAP_32BIT" allows heap_caps_malloc to allocate from IRAM.
-> "MALLOC_CAP_32BIT" allows heap_caps_malloc to allocate from IRAM.
Re: Largest contiguous RAM for HEAP
I think there is this flag, which may influence the behaviour:
CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY
https://docs.espressif.com/projects/esp ... ble-memory
But I can't find this option any more in idf.py menuconfig, it is not in the referenced section
CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY
https://docs.espressif.com/projects/esp ... ble-memory
But I can't find this option any more in idf.py menuconfig, it is not in the referenced section
Re: Largest contiguous RAM for HEAP
This flag is another interesting one https://docs.espressif.com/projects/esp ... e-internal
When SPIRAM allocation with malloc are enabled, it is possible to reserve a block of RAM for "specific needs" such as DMA etc.
If this is enabled, how do the "specific needs" allocate from this reserved memory?
When SPIRAM allocation with malloc are enabled, it is possible to reserve a block of RAM for "specific needs" such as DMA etc.
If this is enabled, how do the "specific needs" allocate from this reserved memory?
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Largest contiguous RAM for HEAP
As usual, via heap_caps_malloc().
Who is online
Users browsing this forum: No registered users and 75 guests