https://kotlinlang.org logo
a

Alex Nabrozidis

07/11/2023, 12:17 PM
Hi, I think there might be a memory leak when using sqldelight (2.0.0-rc02) + Pager, or it could be that I'm using it wrong so I didn't want to create a bug report until someone can tell me whether the code looks fine or not... I've created a project that reproduces the issue https://github.com/nabrozidhs/sqldelight_leak
Copy code
The current implementation of LeakActivity has a memory leak. OffsetQueryPagingSource when used with Pager does not call the unregister method from sqldelight's android driver when the activity finishes. This is the method not being called <https://github.com/cashapp/sqldelight/blob/master/drivers/android-driver/src/main/java/app/cash/sqldelight/driver/android/AndroidSqliteDriver.kt#L92>.

To test it launch the app, tap the button, and then press back when prompted. LeakCanary should eventually detect the leak.
I wanted to confirm whether I'm doing something obvious wrong before submitting a bug report. Edit: I uploaded a leak trace https://github.com/nabrozidhs/sqldelight_leak/blob/main/leaktrace.txt
2 Views