scanBleDevices causes memory leak
See original GitHub issueSummary
Doing a basic scan of ble devices causes a memory leak despite ending the scan subscription at onStop()
.
Library version
1.10.1
Preconditions
Have sample app cloned & loaded: https://github.com/seljabali/rxandroidble2-leak
Steps to reproduce actual result
1. Enable Bluetooth on device
2. Enable GPS
3. Open app
4. Hit back button
5. Pull system drop down
6. Wait for Canary to analyze heap
7. Canary momentarily shows leak.
Actual result
- Canary showing a memory leak
Expected result
- Canary not showing a memory leak
Minimum code snippet reproducing the issue
scanDisposable = RxBle.get()
.scanBleDevices(
ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES)
.build()
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnError {
onScanError() // commenting this out stops leak
}
.doOnNext {
}
.subscribe()
Logs from the application running with settings:
https://github.com/seljabali/rxandroidble2-leak/blob/master/leakLog.txt
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:18 (11 by maintainers)
Top Results From Across the Web
Memory Leak scanning BLE devices - arduino - Stack Overflow
I'm using an ESP32 to scan BLE advertisers but I have a memory leak. If I comment out line 94 (pBLEScan->start) the leak...
Read more >Everything you need to know about Memory Leaks in Android.
How we can cause a leak? A memory leak can easily occur in Android when AsyncTasks, Handlers, Singletons, Threads, and other components are...
Read more >Fix your Android Memory Leaks in Fragments - Procore
Accessing the binding object before onViewCreated is called will cause the app to crash because the DataBinding object inside that delegate hasn't been...
Read more >Preventing and detecting memory leaks in Android apps
Memory leaks can cause your Android app to crash, causing frustration and lower usage. Learn how to fix them in this guide.
Read more >ANR_milanac007的博客-CSDN博客
private IBLEDevice scanBLEDevice(final String sn) throws AKeyException { ... 关键词:Memoryleak/Thread leak ... This will most likely cause the bui.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This looks exactly as before, starting the leak at Android’s
BleScanCallbackWrapper
. I will try to run it once I will get my hands on an API 29 device.Hello, I’ve created a PR with a solution to the issue
https://github.com/Polidea/RxAndroidBle/pull/708
Hope it can be merged soon