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
Merged

Fix BluetoothSerial memory leak #3308

merged 2 commits into from
Oct 1, 2019

Conversation

rafern
Copy link
Contributor

@rafern rafern 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

@me-no-dev
Copy link
Member

good catch :)

@me-no-dev me-no-dev merged commit 40ebee1 into espressif:master Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants