Reducing memory usage when using BLE
Posted: Fri Jan 01, 2021 10:03 am
I am trying to use BLE and WiFi in my project in Platform IO and I use Arduino as the development platform.
I quickly notice that BLE and WiFi are eating almost all the heap I have in ESP32.
I did a quick investigation to see how much heap they will take.
I found out in the code below BLE is taking about 175KB of the heap. Please note that I did add any services and characteristics.
It's almost the same thing with WiFi. Having ESP32 only connect to the WiFi takes about 100KB of the heap.
I am wondering is there any way to reduce/manage the size of the heap being used?
I quickly notice that BLE and WiFi are eating almost all the heap I have in ESP32.
I did a quick investigation to see how much heap they will take.
I found out in the code below BLE is taking about 175KB of the heap. Please note that I did add any services and characteristics.
Code: Select all
#include <Arduino.h>
#include <BLEDevice.h>
void setup()
{
Serial.begin(115200);
Serial.println("Free heap is " + String(ESP.getFreeHeap()));
BLEDevice::init("deviceName");
Serial.println("+BLE => Free heap is " + String(ESP.getFreeHeap()));
}
void loop()
{
}
I am wondering is there any way to reduce/manage the size of the heap being used?