<@U3SK5B492> How expensive is attaching and detach...
# kotlin-native
s
@olonho How expensive is attaching and detaching an object from a thread? If I have a List with 100,000 items, should I worry about performance for attaching and detaching objects from a thread?
o
currently, it’s
O(subgraph_size)
, but the constant is pretty small
s
thx
k
Sort of related (but only because of detached object graphs). If something in your detached graph references something outside of your detached graph, does the reference count decrement when you detach, and if not, if you never attach again, is that memory effectively leaked? Was playing around with state and that thought popped into my head.
o
The only case it could happen is for frozen objects, and yes, such objects will be leaked
k
I was just playing with some state and thought I was capturing unfrozen state, but I was probably freezing it unintentionally
Yeah, I guess you’d have bigger problems detaching unfrozen state. Had a red eye flight and didn’t sleep. Slow brain
o
well, there’s no problem detaching frozen/permanent state, we can just consider those being “outer” to detached graph and shareable by default, so they not block detaching
k
Right. Just saying trying to detach non-frozen state is obviously a bad plan
I mean references to