Skip to content

Makeing queries in a loop doesn't release resources. #24

@MrSpock

Description

@MrSpock

Hi,
I have an app that is working as a daemon and after acquiring adapter is making queries then sleeps and make ble operations again.
Afer some time there is a lot open sockets and after few hours apps crashes due to exausting system resources. After few hours.

xiaomi-se 11289 root  524u  sock                0,9      0t0 1009087 protocol: HCI
xiaomi-se 11289 root  525u  sock                0,9      0t0 1009088 protocol: L2CAP
xiaomi-se 11289 root  526u  sock                0,9      0t0 1010309 protocol: HCI
xiaomi-se 11289 root  527u  sock                0,9      0t0 1010312 protocol: L2CAP

root@fx160:/proc/11289# lsof -n -p 11289|less|grep L2CAP|wc -l
198
root@fx160:/proc/11289# lsof -n -p 11289|less|grep HCI|wc -l
297

Code is basic:
There is function returning available adapter that is then used in a loop:

// return running ble interface
fn prepare_ble_interface() -> rumble::bluez::adapter::Adapter 
// inside main()
let ble_iface = prepare_ble_interface();
loop {
// make ble queries using ble_iface
//sleep for some time
}

I've tried to call prepare_ble_interface() outside loop and within where it should be deallocated every iteration. No changes. Until program is running number of open BLE sockets is increasing with every connection to ble device.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions