esp32-snippets: Does "BLEScan::start()" has issue of memory leak?
Hi.
We’d like to use “BLEScan::start()” for receive “Advertising Data” including sensor value permanently. We’ve tried use it by below program, but ESP32 had restarted by lack HeapSize.
void setup() {
Serial.begin(115200);
BLEDevice::init("");
pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true);
}
void loop() {
Serial.print("Free HeapSize: ");
Serial.println(esp_get_free_heap_size());
pBLEScan->start(3);
delay(1000);
}
Shouldn’t “BLEScan::start()” called from “loop()” function? Or does “BLEScan::start()” has issue of memory leak?
Please could you confirm this question?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 25
@kymybk Ok, i found that memory leak in BLEScan. I am working now on multi connect implementation and i have to change a little bit BLEScan class so it will be fixed in it. Thanks again for reporting and help with tests.
If you want to fix it just for now then it is here: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/BLEScan.cpp#L201
Object is deleted from vector but is not destroyed.
Before it will be merged to library you can get it from this gist: https://gist.github.com/chegewara/6fc38e4127a7e18bb5b0bb4367aa33d1
I know its quite old issue, sorry for delay, but i am working on few updates and i have this on todo list. https://github.com/chegewara/esp32-snippets/issues/7