Hello I have code consist of a lot of functions how can I compute the consumed memory by this code ?
I use esp32
What exactly do you mean by the memory consumed by the code and what are N and N2 ?
Have you got verbose output during compiling turned on in preferences ? What does the compiler report when you compile the sketch ?
After answering the questions from post#2.
Are you using freeRTOS tasks on the ESP32 and you need to set task stack sizes?
With the proper ESP32 partition settings you can get 3MB of RAM for program use with an ESP32. Are you running out of RAM?
Using the search feature of the API Reference - ESP32 - — ESP-IDF Programming Guide latest documentation one can find the various macros that the ESP32 has to show the various ram size used. When running on the ULP core the memory stack size reports are not functional.
I need to print in serial monitor something like :
The total memory consumed by this code is= " " KB . Is there any code that I can use it?
See the ESP32's API as linked to previously for code to print the various memory stacks.
void fProcessAirPressure ( void *pvParemeters )
{
int Ticks = 118; // Tick counter
bool Filled = false; // array has been filled before?
float *ptr = CollectionPressure; // pointer to the array
const int ticksTrigger = 120; // triggered at 1 minute intervals
for (;;)
{
//triggered by BME which is triggered by the 1 minute hardware timer.
xEventGroupWaitBits (eg, evtStoreAirPressure, pdTRUE, pdTRUE, portMAX_DELAY );
xSemaphoreTake( sema_CollectPressure, portMAX_DELAY );
xSemaphoreTake ( sema_eData, portMAX_DELAY );
if ( !Filled )
{
//if array has not been filled before, fill array with the same base value
for ( int j = 0; j < BufferCount; j++ )
{
*( ptr + j ) = x_eData.oPressure;
}
Filled = true;// array has been initially filled
} else {
if ( Ticks == ticksTrigger )
{
//when tick counter reaches the trigger level
//shift contents left and insert new value at the end
for ( int i = 0; i <= BufferCount - 2; i++ )
{
*( ptr + i ) = *( ptr + (i + 1) );
}
}
*( ptr + (BufferCount - 1) ) = x_eData.oPressure;//new value to be inserted
}
// find and store highest and lowest value
if ( x_eData.oPressure > x_eData.PressureH )
{
x_eData.PressureH = x_eData.oPressure;
}
if ( x_eData.oPressure < x_eData.PressureL )
{
x_eData.PressureL = x_eData.oPressure;
}
Ticks++;
if ( Ticks > ticksTrigger )
{
Ticks = 1;
}
//log_i( "ticks %d" , Ticks );
x_eData.cngPress = CalculatePressureFactors( *( ptr + 57), *( ptr + 59) ); // going back 4 hours
xSemaphoreGive( sema_eData );
xSemaphoreGive( sema_CollectPressure );
//
log_i( " high watermark % d", uxTaskGetStackHighWaterMark( NULL ) );
} //for (;;)
vTaskDelete( NULL );
} //void fStoreAirPressure ( void *pvParemeters )
The above code prints out the stack space used by the freeRTOS task.
If you compile the code without uploading it the compiler prints a message about flash and RAM-usage in bytes and in percent.
This is done on compile-time. You could simply put these numbers in some serial.print-commands
The ESP32 has a lot of RAM. As long as you do not combine WiFi with a bluetooth HID-device functionality you are not in danger to ran out of RAM or flash.
Except maybe you are using really huge arrays in your code.
best regards Stefan
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.