Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak issue with gattlib and glib #202

Open
ravi-vt opened this issue Feb 26, 2021 · 2 comments
Open

Memory leak issue with gattlib and glib #202

ravi-vt opened this issue Feb 26, 2021 · 2 comments

Comments

@ravi-vt
Copy link

ravi-vt commented Feb 26, 2021

I have found some memory leaks with gattlib and glib.

For gattlib, I am getting a memory leak from "gattlib_adapter_open".
I observed leaks in glib also. this block leaking too much memory that we can't afford.
I found these memory leaks using Valgrind. its log is as below.

==2700== 200 (160 direct, 40 indirect) bytes in 8 blocks are definitely lost in loss record 11 of 31
==2700== at 0x4842590: calloc (vg_replace_malloc.c:752)
==2700== by 0x4A85BB7: gattlib_adapter_open (in /usr/lib/libgattlib.so)

==2700== 29,288 (7,840 direct, 21,448 indirect) bytes in 280 blocks are definitely lost in loss record 27 of 31
==2700== at 0x483F970: malloc (vg_replace_malloc.c:299)
==2700== by 0x49D9E7B: g_malloc (in /usr/lib/libglib-2.0.so.0.5800.3)

Please provide some patches or solutions to resolve the leak issue.

Thank you.

@vl-80
Copy link
Contributor

vl-80 commented Feb 21, 2022

@ravi-vt

If you are still experiencing this problem try this patch and see if the memory is still leaking:

vl-80@a0f68ea

@vl-80
Copy link
Contributor

vl-80 commented Feb 23, 2022

@oliviermartin ,

Can you please check this diff: vl-80@a0f68ea and see if it is necessary to unref the conn_context->adapter->adapter_proxy in gattlib_disconnect()?

It is allocated here:

adapter_proxy = org_bluez_adapter1_proxy_new_for_bus_sync(
G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
"org.bluez",
object_path,
NULL, &error);

And it appears that it is not freed anywhere else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants