Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BluetoothSerial memory leak #3308

Merged
merged 2 commits into from Oct 1, 2019

Conversation

@rafern
Copy link
Contributor

commented Sep 30, 2019

An easy way to trigger this leak is to only send packets with a size multiple and greater than SPP_TX_MAX (i.e. 660 bytes of data). This example will easily make the device run out of memory:

#include "BluetoothSerial.h"
BluetoothSerial SerialBT;

void setup() {
  Serial.begin(115200);
  SerialBT.begin("ESP32test");
}

void loop() {
  log_i("Free heap: %zu", ESP.getFreeHeap());
  SerialBT.write((uint8_t*)"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cil.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cil..Duis aute irure dolor in reprehenderit in voluptate velit ..", 660);
  delay(20);
}

Note that you must connect a device via bluetooth to the esp for the messages to start sending, else, this program does nothing as no messages are being sent

rafern and others added 2 commits Sep 30, 2019
@me-no-dev

This comment has been minimized.

Copy link
Member

commented Oct 1, 2019

good catch :)

@me-no-dev me-no-dev merged commit 40ebee1 into espressif:master Oct 1, 2019
21 checks passed
21 checks passed
Arduino 0 on ubuntu-latest
Details
Arduino 1 on ubuntu-latest
Details
Arduino 2 on ubuntu-latest
Details
Arduino 3 on ubuntu-latest
Details
Arduino 4 on ubuntu-latest
Details
Arduino 5 on ubuntu-latest
Details
Arduino 6 on ubuntu-latest
Details
Arduino 7 on ubuntu-latest
Details
Arduino 8 on ubuntu-latest
Details
Arduino 9 on ubuntu-latest
Details
Arduino 10 on ubuntu-latest
Details
Arduino 11 on ubuntu-latest
Details
Arduino 12 on ubuntu-latest
Details
Arduino 13 on ubuntu-latest
Details
Arduino 14 on ubuntu-latest
Details
Arduino on windows-latest
Details
Arduino on macOS-latest
Details
PlatformIO on ubuntu-latest
Details
PlatformIO on windows-latest
Details
PlatformIO on macOS-latest
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.