-
Notifications
You must be signed in to change notification settings - Fork 4
Current memory use of a simple Blink sketch
Dirk O. Kaar edited this page Nov 13, 2019
·
7 revisions
blink sketch
Executable segment sizes
IROM *: 228440 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM *: 26564 \ 32768 - code in IRAM (ICACHE_RAM_ATTR, ISRs...)
DATA *: 1236 ) - initialized variables (global, static) in RAM\HEAP
RODATA *: 1528 ) \ 81920 - constants (global, static) in RAM\HEAP
BSS *: 25208 ) - zeroed variables (global, static) in RAM\HEAP
Program size: 257,768 bytes (used 25% of a 1,044,464 byte maximum) (2.45 secs)
Minimum Memory Usage: 27972 bytes (34% of a 81920 byte maximum)
using CoopTask
Executable segment sizes
IROM *: 237996 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM *: 26900 \ 32768 - code in IRAM (ICACHE_RAM_ATTR, ISRs...)
DATA *: 1244 ) - initialized variables (global, static) in RAM\HEAP
RODATA *: 1652 ) \ 81920 - constants (global, static) in RAM\HEAP
BSS *: 25504 ) - zeroed variables (global, static) in RAM\HEAP
Program size: 267,792 bytes (used 26% of a 1,044,464 byte maximum) (5.27 secs)
Minimum Memory Usage: 28400 bytes (35% of a 81920 byte maximum)
CoopTask adds:
IROM: 9556
IRAM: 336
DATA: 8
RODATA: 124
BSS: 296
Program size: 10,024
Minimum Memory Usage: 428
blink sketch
Compiling 'CoopMemoryTest' for 'ATmega328P (3.3V, 8 MHz) (Arduino Pro or Pro Mini)'
Program size: 928 bytes (used 3% of a 30,720 byte maximum) (1.09 secs)
Minimum Memory Usage: 9 bytes (0% of a 2048 byte maximum)
using CoopTask
Compiling 'CoopMemoryTest' for 'ATmega328P (3.3V, 8 MHz) (Arduino Pro or Pro Mini)'
Program size: 5,510 bytes (used 18% of a 30,720 byte maximum) (0.97 secs)
Minimum Memory Usage: 161 bytes (8% of a 2048 byte maximum)
CoopTask adds:
Program size: 4582
Minimum Memory Usage: 152
blink sketch
Program size: 259,145 bytes (used 20% of a 1,310,720 byte maximum) (5.01 secs)
Minimum Memory Usage: 15564 bytes (5% of a 327680 byte maximum)
using CoopTask
Program size: 263,105 bytes (used 20% of a 1,310,720 byte maximum) (5.81 secs)
Minimum Memory Usage: 15668 bytes (5% of a 327680 byte maximum)
CoopTask adds:
Program size: 3,960
Minimum Memory Usage: 104
/*
Created: 2019-11-12 13:14:04
*/
#define USECOOPTASK
#ifdef USECOOPTASK
#include <CoopTaskBase.h>
#include <CoopTask.h>
#include <CoopSemaphore.h>
#include <CoopMutex.h>
#include <BasicCoopTask.h>
#endif
#if defined(ESP32) || defined(ESP8266)
#include <functional>
#endif // defined(ESP32) || defined(ESP8266)
void blink()
{
digitalWrite(LED_BUILTIN, LOW);
delay(100);
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
}
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
#ifdef USECOOPTASK
#ifdef ESP8266
CoopTaskBase::useBuiltinScheduler();
#endif
createCoopTask("blink", []() { for (;;) blink(); return 0; });
#endif
}
// std::function on ESP32 needs over 50K program size alone - level playing field for the demonstration:
#if !defined(USECOOPTASK) && defined(ESP32)
std::function<void()> dummyFunction = []() {};
#endif // !defined(USECOOPTASK) && defined(ESP32)
#if defined(USECOOPTASK) && !defined(ESP8266)
auto reaper = [](const CoopTaskBase* const) {};
#endif // defined(USECOOPTASK) && !defined(ESP8266)
void loop()
{
#ifndef USECOOPTASK
blink();
#ifdef ESP32
dummyFunction();
#endif // ESP32
#elif !defined(ESP8266)
runCoopTasks(reaper);
#endif
}