0

So, we have a kotlin wrapper around vulkan which relies on inline classes for vulkan identifiers (which are usually Longs)

As far as I got, Java (9+) Cleaner is supposed to work only with classes.

Here an example

I tried to modify that in order to run with plain primitives

fun main() {
    val cleaner = Cleaner.create()
    for (i in 0..9) {
        val id = Integer.toString(i)
        val vkObject = 0L + i
        cleaner.register(vkObject, CleanerRunnable(id))
    }

    //myObjects are not reachable anymore
    //do some other memory intensive work
    for (i in 1..10000) {
        val a = IntArray(10000)
        try {
            Thread.sleep(1)
        } catch (e: InterruptedException) {
        }

    }
}

But unfortunately without success.

So my question is if there is a way to have Cleaner working with primitives representing native off-heap resources without having to wrap them in classes

elect
  • 6,765
  • 10
  • 53
  • 119

0 Answers0