touchlab-lab / knarch.db

K(otlin)N(ative)A(rchitecture) Database
https://touchlab.co/
Apache License 2.0
90 stars 9 forks source link

Review CursorWindow data scheme #9

Open kpgalligan opened 6 years ago

kpgalligan commented 6 years ago

In Android and the c++ code, the data for the window is explicitly created and destroyed. In cases where 'close' isn't called explicitly, the finalize method will eventually free this memory. KN does not have a finalize. To achieve the same effect, we create a ByteArray in the Kotlin code, then give the pointer address of the start of that array, and when we want to clear that ByteArray, set it to null. It should free the memory immediately, but we should do some checking that this actually happens when expected.