labapart / gattlib

Library to access GATT information from BLE (Bluetooth Low Energy) devices
http://labapart.com/
436 stars 157 forks source link

fix memory leak errors #216

Open chenbinn opened 3 years ago

chenbinn commented 3 years ago

"{&sv}" format string in loop, no need free the key. see "https://developer.gnome.org/glib/stable/gvariant-format-strings.html" section "Characters: &".

kaifastromai commented 3 years ago

I would strongly recommend merging this commit. It fixes a really annoying 'memory freeing' bug.

luknowak commented 1 year ago

Hi @oliviermartin, would you be able to merge this pull request, which fixes a big memory leak, please? It's enough to run gattlib_connect() and gattlib_disconnect() in a loop, to leak over 8MB in every iteration. Such leak makes it impossible to use the library for any long-running apps. Thanks.

luknowak commented 1 year ago

There is an additional memory leak, not covered by this pull request, which needs to be fixed. When gattlib_connect() is called with adapter=NULL, and something fails in the function (e.g. device fails to connect), the default adapter is not being closed - the gattlib_adapter_close() is called only when the adapter is provided by the caller.