espressif / esp-idf-provisioning-ios

Apache License 2.0
134 stars 64 forks source link

Memory leaks in ESPProvision Library #73

Open pklobukowski opened 1 year ago

pklobukowski commented 1 year ago

Description

Some of the ESPProvision Library objects like ESPBleTransport, ESPSession, ESPDevice, ESPWiFiManager, ESPProvision, ESPUtility and also object related to security schemes remain in memory, instead of being deallocated, which leads to memory leaks issues on iOS.

Memory leaks

To Reproduce I detect this problem in my project, but it should be visible also in Sample App. In the link below you can read about how to detect memory leaks in Xcode : https://medium.com/@lvjian700/advanced-debug-swift-memory-leak-eb134b061158

Example steps to reproduce the behavior in Sample App:

  1. Open Sample App
  2. Click on 'Provision Device'
  3. Click on 'I don't have a QR code'
  4. Connect with BLE device
  5. On 'Select Wi-Fi Network' (even during searching wifi networks) click on 'Cancel'
  6. Repeat previous steps multiple times

Frequency Every time

Expected behavior All retained objects should be deallocated. There should be no memory leaks warnings in Xcode

Screenshots Here are multiple screenshots with memory graphs that I discovered during debuging.

After finding new device via BLE without provisioning Screenshot 2 After finding new device via BLE after successful provision

ESP Device Information: Doesn't matter. Its only iOS related problem.

iOS information: It will show on every iOS device. I used Xcode 15 and Xcode 14.3.1 for debbuging

Provisioning information:

vikas-chandra-mnnit commented 1 year ago

Thanks, @pklobukowski for posting here your detailed observation. We will take it forward and optimize the memory issues in our library.

vikas-chandra-mnnit commented 11 months ago

@pklobukowski, I've followed all the outlined steps with the ESPSampleApp. Regrettably, I didn't come across any memory leak warnings during debugging. Please inform us if there are any disparities in how the SDK is utilized in your application compared to the sample app, or if there are any extra measures we can attempt to replicate this problem. Appreciate your assistance.