maximkulkin / esp-homekit

Apple HomeKit accessory server library for ESP-OPEN-RTOS
MIT License
1.11k stars 170 forks source link

Memory Leak when connecting with HomeApp #35

Closed Arduingo closed 6 years ago

Arduingo commented 6 years ago

During some experiments with the framework using the demos I´m observing a behavior I´m not sure its the expected.

I compiled the example with DEBUG ON, after reboot, pairing and normal configuration I observed that each time the HomeApp is opened in my iPhone the heap in the code running in my test device is reduced by aprox. 48 Bytes in average. Actually if between open and closes of the homeApp I wait about 30 secs the 48 bytes of reduction is quite constant, what is sure is the memory lost is not recovered by waiting any longer.

After some days of operation the code crash and the device in most of the cases is unable to reset itself and hang showing no response in the HomeApp.

Second fatal exception occured inside fatal exception handler. Can't continue. ets Jan 8 2013,rst cause:1, boot mode:(1,6) ets Jan 8 2013,rst cause:4, boot mode:(1,6) wdt reset

Steps to reproduce: 1) Boot device 2) Open HomeApp, note heap size 3) wait 30 secs 4) Close HomeApp 5) Wait 30 Secs 6) Open Home App, note heap size reduced 7) Repeat from 3

Seems like the leak is at the homekit_server_on_get_characteristics function, but I´m not sure of this.

Attached a log showing the heap going from 12124 to 11000

HomekIt_Leak.txt