In my multiplatform project I need to work with bignums. In the JVM and JS targets, this is easy and I’ve created a wrapper around the built-in bignum functionality on those platforms.
On Linux, I leverage the gmp library to achieve the same goal. In gmp, when you’re done with a value, you need to call mpz_clear to release the memory used by the bignum.
I’ve noticed that the finalize function does not work in Kotlin Native, so what is the solution here? Due to the nature of the project, explicit scoping for these values is not an option. I somehow need to know when the Kotlin object that wraps the gmp value is garbage collected.
Is there a solution to this problem?