You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add ATTClass end function to clean up _peers and call from BLELocalDevice::end()
can lead to memory leaks for _peers[i].device and other issues, especially if disconnect does not not happen nicely
call retain twice GATTClass::addService(..)
This is needed for 4, otherwise will cause a premature delete issue
voidGATTClass::addService(BLELocalService* service)
{
service->retain();
_attributes.add(service);
uint16_t startHandle = attributeCount();
for (unsignedint i = 0; i < service->characteristicCount(); i++) {
BLELocalCharacteristic* characteristic = service->characteristic(i);
characteristic->retain();
_attributes.add(characteristic);
characteristic->setHandle(attributeCount());
// add the characteristic again to make space of the characteristic value handle
characteristic->retain(); // IMPORTANT: call this again since we are adding it twice
_attributes.add(characteristic);
......
}
perform clean-up in GATTClass::end()
Need to preform proper housekeeping here, otherwise it will lead to memory leaks.
voidGATTClass::end()
{
clearAttributes(); // call this instead of _attributes.clear();
}
The text was updated successfully, but these errors were encountered:
dreamstyler
changed the title
Fixes for various memory leaks
Fixes for memory leaks for Peers and around Services, Characteristics and Descriptors
Oct 18, 2020
The following function should have a timeout to prevent getting locked up in some error condition.
Might be good to have a way for the user to detect if such errors happen so they can take action.
intHCIClass::sendAclPkt(uint16_t handle, uint8_t cid, uint8_t plen, void* data)
{
constunsignedlong start = millis();
while (_pendingPkt >= _maxPkt) {
Serial.print(';');
constint a = poll();
if (a < 0)
Serial.print(a);
if (millis() > (start + 3000))
{
Serial.println("HCIClass::sendAclPkt TIMEOUT");
break;
}
}
Ideally, all while loops should have a timeout guard if they poll some peripheral.
I found some other issues after posting this #127
can lead to memory leaks for _peers[i].device and other issues, especially if disconnect does not not happen nicely
Needed for 3 otherwise will delete BLELocalDescriptor prematurely.
This is needed for 4, otherwise will cause a premature delete issue
Need to preform proper housekeeping here, otherwise it will lead to memory leaks.
The text was updated successfully, but these errors were encountered: