Skip to content

Commit 1416e22

Browse files
Docs: update: Debug suspend functions as separate section
1 parent 8e7a7bb commit 1416e22

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

docs/topics/coroutines-basics.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,28 @@ suspend fun doWorld() {
105105
```
106106
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
107107

108-
You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-basic-02.kt).
108+
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-basic-02.kt).
109+
>
110+
{type="note"}
109111

110112
<!--- TEST
111113
Hello
112114
World!
113115
-->
114116

115-
> If you use `suspend` functions, in the debugger, you might see the "was optimised out" text next to a variable's name:
116-
> ![Variable "a" was optimised out](variable-optimised-out.png)
117-
> This text means that the variable's lifetime was decreased, and the variable doesn't exist anymore.
118-
> Debugging code with optimised variables is hard because you don't see their values.
119-
> You can disable this behavior with the `-Xdebug` compiler option.
117+
## Debug suspend functions
118+
119+
If you use `suspend` functions, in the debugger, you might see the "was optimised out" text next to a variable's name:
120+
121+
![Variable "a" was optimised out](variable-optimised-out.png)
122+
123+
This text means that the variable's lifetime was decreased, and the variable doesn't exist anymore.
124+
Debugging code with optimised variables is hard because you don't see their values.
125+
You can disable this behavior with the `-Xdebug` compiler option.
126+
120127
> __Never use this flag in production__: `-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).
121128
>
122-
{type="tip"}
129+
{type="warning"}
123130

124131
## Scope builder
125132

0 commit comments

Comments
 (0)