[feature] Free a little memory used by bluetooth if wifi is enabled or bluetooth is disabled (#10398)

* esp32: release BTDM heap when Bluetooth inactive

Release ESP-IDF BTDM memory after config load when Bluetooth is disabled or WiFi is enabled, recovering heap on ESP32 targets where BLE won’t be used for this boot.

* Address BT memory release review comments

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Clive BlackledgeandBen Meadors authored and GitHub committed 2026-06-25 17:05:27 -05:00
1 parent f1b1e35a79
commit 98fa4a67db
4 files changed
+82 -1

No files matched your search

+5
View File
@@ -792,6 +792,11 @@ void setup()
// We do this as early as possible because this loads preferences from flash
// but we need to do this after main cpu init (esp32setup), because we need the random seed set
nodeDB = new NodeDB;
#ifdef ARCH_ESP32
// Config is loaded now, and Bluetooth has not been initialized yet. If the
// saved config will keep Bluetooth inactive, return its reserved memory early.
esp32ReleaseBluetoothMemoryIfUnused();
#endif
// Initialize transmit history to persist broadcast throttle timers across reboots
TransmitHistory::getInstance()->loadFromDisk();