Like js "delete"
# javascript
l
Like js "delete"
t
what you want to do exactly?
l
free memory In chrome heap snapshot I can find object, should not be there
t
Weird, you are sure about it, that you have no references about it somewhere ?
l
Idk, how I can detect them?
All code is in the functions, no globals
I can't imagine where I could leave cross links
t
What is the object that should not be here?
l
My custom packets. I receive packets from server, deserialize them and get some packet, then I use packet load (entities, store them in app) and after that packet should be deleted from memory.
But I see a lot of them in heap @Tristan Caron
t
Even when you force the garbage collector?
l
How?
t
If you use chrome, in DevTools, tab
memory
, you have a trash icon in the left corner. For others, I do not know.
a
@lewik There is an old answer on Stackoverflow: https://stackoverflow.com/questions/28401523/how-do-you-call-javascript-delete-from-kotlin Since then keyword
native
was replaced with `external`:
Copy code
external fun delete(p: dynamic): Boolean

fun delete(thing: dynamic, key: String) {
  delete(thing[key])
}

fun String.deleteFrom(d: dynamic) {
  delete(d[this])
}

fun test(a: Any, k: String) {
    delete(a, k)
    k.deleteFrom(a)
}