https://kotlinlang.org logo
#feed
Title
# feed
d

diego-gomez-olvera

03/23/2021, 2:19 PM
the cost of creating Java Threads, a plus for Kotlin + Coroutines https://dzone.com/articles/java-threads-may-not-be-memory-efficient
This study clearly indicates that memory is allocated to threads at the time of creation, and memory is not allocated based on the thread’s runtime demand. Both hyper working threads and almost dormant threads consume the same amount of memory. Modern Java applications tend to create hundreds (sometimes thousands) of threads. But most of those threads are in a WAITING or TIMED_WAITING state and do nothing.
k

Kris Wong

03/23/2021, 2:39 PM
interesting experiment. entirely predictable result though. that's just how the stack works.
d

Dariusz Kuc

03/23/2021, 2:55 PM
It looks like they run it using very old (as in Java 8 ) version which was eagerly allocating the memory to the threads. It does not do that in Java 11. see: https://dzone.com/articles/how-much-memory-does-a-java-thread-take
k

Kris Wong

03/23/2021, 4:00 PM
they changed the stack to support dynamic sizing?
interesting. pthreads works in the same way as the older Java model.
s

suresh

03/23/2021, 4:50 PM
Dynamic stack sizing is will be available in project loom, which will allow us to create millions of threads

https://youtu.be/7GLVROqgQJY

3 Views