Skip to content

pCharacteristic->notify() memory leak #8413

@raphael-bmec-co

Description

@raphael-bmec-co

Board

Esp32devkit

Device Description

Plane module

Hardware Configuration

NA

Version

v2.0.9

IDE Name

CLion with platformIO

Operating System

Windows 11

Flash frequency

80

PSRAM enabled

yes

Upload speed

115200

Description

When calling notify @ ~10x/second with an MTU of 50-247, some backlog occurs, causing a memory leak and eventually the server becomes unresponsive to the client and logs esp_ble_gatts_send_ notify: rc=-1 Unknown ESP_ERR error.

The issue can be resolved by changed from 'notify' to 'indicate'. However, this is less performant and there is a clear leak if notifies fail to be received in full by a client.

Sketch

The BLE notify example sketch works fine. Just change the MTU - needs to be done client side to 247.

Debug Message

esp_ble_gatts_send_ notify: rc=-1 Unknown ESP_ERR error

Other Steps to Reproduce

Issues exists from 2.0.3 to 2.0.9. I have found from scattered mentions around the internet from years ago about a buffer getting full. I suspect the memory is still allocated as the read is still in progress when the next notify comes along and the memory is not freed correctly clogging up the buffer.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions