Skip to content

Commit 8651d7b

Browse files
Docs: add tip about -Xdebug to disable "was optimise out" feature
1 parent 3788889 commit 8651d7b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

docs/topics/debug-coroutines-with-idea.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,11 @@ The tutorial assumes you have prior knowledge of the [coroutines](coroutines-gui
9999
* The second coroutine has computed its value and disappeared.
100100
* The third coroutine is calculating the value of `b` – it has the **RUNNING** status.
101101

102+
> You can disable a "was optimised out" feature via the `-Xdebug` compiler option.
103+
> The "was optimised out" feature optimizes variables when you use suspend functions.
104+
> However, debugging a code with optimized variables is hard because you don't see their values.
105+
> Be careful: disabling this feature via `-Xdebug` can [cause memory leaks](https://youtrack.jetbrains.com/issue/KT-48678/Coroutine-debugger-disable-was-optimised-out-compiler-feature#focus=Comments-27-6015585.0-0).
106+
>
107+
{type="tip"}
108+
102109
Using IntelliJ IDEA debugger, you can dig deeper into each coroutine to debug your code.

docs/topics/debug-flow-with-idea.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ Create a Kotlin [flow](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-cor
102102

103103
![Debug the coroutine](flow-debug-2.png)
104104

105+
> You can disable a "was optimised out" feature via the `-Xdebug` compiler option.
106+
> The "was optimised out" feature optimizes variables when you use suspend functions.
107+
> However, debugging a code with optimized variables is hard because you don't see their values.
108+
> Be careful: disabling this feature via `-Xdebug` can [cause memory leaks](https://youtrack.jetbrains.com/issue/KT-48678/Coroutine-debugger-disable-was-optimised-out-compiler-feature#focus=Comments-27-6015585.0-0).
109+
>
110+
{type="tip"}
111+
105112
## Add a concurrently running coroutine
106113
107114
1. Open the `Main.kt` file in `src/main/kotlin`.

0 commit comments

Comments
 (0)