Where's the rest of the internal memory?

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Where's the rest of the internal memory?

Postby vonnieda » Fri Dec 01, 2017 8:05 pm

I started to run into some memory issues in my project this morning, so I am spending some time debugging memory. I noticed there seems to be less internal memory than the datasheet indicates and am wondering how to access it.

I'm using a WROVER32KIT v3 and if I build the following tiny app, it reports "227560" on startup.

Code: Select all

#include "sdkconfig.h"
#include "esp_system.h"
#include "esp_log.h"

#define TAG "TEST"

void app_main()
{
	ESP_LOGI(TAG, "%d", esp_get_free_heap_size());
}
The datasheet says that the ESP32 has "520 kB (8 kB RTC FAST Memory included) of on-chip SRAM for data and instructions." So where is the other 290k hiding, and is there a way to use it?

FWIW: I'm aware of the SPI RAM, and am using it in my project. This came about because I ran out of internal RAM specifically when allocating FreeRTOS task stacks.

Thanks in advance for any light you can shine!

Thanks,
Jason

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Where's the rest of the internal memory?

Postby WiFive » Sat Dec 02, 2017 5:48 am

Code: Select all

heap_caps_get_free_size(MALLOC_CAP_8BIT)
heap_caps_get_free_size(MALLOC_CAP_32BIT)
First will show DRAM, second will show DRAM+IRAM

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Re: Where's the rest of the internal memory?

Postby vonnieda » Sat Dec 02, 2017 5:13 pm

WiFive wrote:

Code: Select all

heap_caps_get_free_size(MALLOC_CAP_8BIT)
heap_caps_get_free_size(MALLOC_CAP_32BIT)
First will show DRAM, second will show DRAM+IRAM
Thank you for the response WiFive, but I'm still not seeing the full amount. Here's the new test program and output:

Code: Select all

#include "esp_system.h"
#include "esp_log.h"
#include "esp_heap_caps.h"

#define TAG "TEST"

void app_main()
{
    ESP_LOGI(TAG, "MALLOC_CAP_8BIT %d", heap_caps_get_free_size(MALLOC_CAP_8BIT));
    ESP_LOGI(TAG, "MALLOC_CAP_32BIT %d", heap_caps_get_free_size(MALLOC_CAP_32BIT));
}
I (256) TEST: MALLOC_CAP_8BIT 299304
I (256) TEST: MALLOC_CAP_32BIT 395940

So it seems like there is at least another 124k missing?

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Where's the rest of the internal memory?

Postby ESP_igrr » Sun Dec 03, 2017 3:19 am

There is also statically allocated memory (both IRAM and DRAM), you can see the amount by running "make size". Plus a 64kB region of IRAM used for CPU caches.

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Re: Where's the rest of the internal memory?

Postby vonnieda » Tue Dec 05, 2017 4:23 am

ESP_igrr wrote:There is also statically allocated memory (both IRAM and DRAM), you can see the amount by running "make size". Plus a 64kB region of IRAM used for CPU caches.
Thank you ESP_igrr, I think that clears it up for me. If I add up all those numbers I get close enough to 520k.

Thanks,
Jason

Who is online

Users browsing this forum: No registered users and 90 guests