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

dhr039

09/30/2023, 9:34 AM
any idea why the following :
Copy code
fun main() {
    repeat(1_000_000) {
        thread {
            Thread.sleep(5000)
            print(".")
        }
    }
}
is not giving an OutOfMemoryError anymore? It was giving it two months ago. Now it is just working a lot more slowly than the coroutines version. I'm using
Android Studio Giraffe | 2022.3.1 Patch 1
+
kotlin-stdlib 1.6.21
The original source code: 7_starting_lots_of_threads.kt
a

azabost

09/30/2023, 9:51 AM
Gives OOM in play.kotlinlang.org 🤔
y

Yonatan Karp-Rudin

09/30/2023, 7:57 PM
I assume you’re not using virtual threads by mistake 🫣 🤣
d

dhr039

10/01/2023, 8:57 AM
Created a new Android project and tested the same code there - OOM was thrown. Went back to the previous project that was not giving OOM to test again - and this time it was an OutOfMemoryError . Checked the project files, none were changed in any way, git had nothing to commit. So it must be something in my local setup. It feels like a brand new toy has been shown to you and then suddenly taken away. I was already looking forward an investigation.
2 Views