# compose


11/06/2020, 1:07 AM
Is there a way to inform the composer that data has been written to a list that doesn't involve duplicating said list each time I need to update it? I'm updating said list at 50Hz which feels like undue strain to put on the GC if im leaking that much memory

Adam Powell

11/06/2020, 1:11 AM
might be useful in your situation
You can use the
composable property to get an invalidation function for the current scope, then you can call it elsewhere when you would like that scope to recompose
It's kind of running with scissors though and I would not recommend it for this use case, especially since you're likely to hit thread safety problems sharing unsafe mutable data with a composition
Snapshot state is always thread safe


11/06/2020, 1:42 AM
The list is being updated from a LiveData in the composable's scope so I don't think thread unsafety is an issue here. Are there any docs for that invalidate property?
Seems like I was just overcomplicating it, just turning the LiveData into a State directly and pushing its value into the buffer works instead of what i was trying to do before.

Zach Klippenstein (he/him) [MOD]

11/06/2020, 2:03 AM
It could be a thread safety issue in the future once compose starts doing stuff on multiple threads though. Also generally, sharing mutable state gets hard to reason about as code area and scales.
You might also want to check out the kotlinx.immutable library for list implementations that are optimized for this sort of use
☝️ 1
And not to be pedantic, but unless you’re doing something very weird, what you described might be putting some pressure on the garbage collector but it shouldn’t be leaking memory