Skip to content

Commit 2afcbbc

Browse files
authored
update: K/N overview and diagrams (#4803)
1 parent c32692c commit 2afcbbc

File tree

7 files changed

+66
-61
lines changed

7 files changed

+66
-61
lines changed
Lines changed: 4 additions & 0 deletions
Loading
Binary file not shown.
-27.8 KB
Binary file not shown.

docs/topics/native/apple-framework.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ You can find more information about type mapping in [Interoperability with Swift
326326
## Garbage collection and reference counting
327327

328328
Swift and Objective-C use automatic reference counting (ARC). Kotlin/Native has its own [garbage collector](native-memory-manager.md#garbage-collector),
329-
which is also [integrated with Objective-C/Swift ARC](native-arc-integration.md).
329+
which is also [integrated with Swift/Objective-C ARC](native-arc-integration.md).
330330

331331
Unused Kotlin objects are automatically removed. You don't need to take additional steps to control the lifetime of
332332
Kotlin/Native instances from Swift or Objective-C.

docs/topics/native/native-arc-integration.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,24 @@ cannot be run during the GC pause.
249249

250250
In a _retain cycle_, a number of objects refer each other using strong references cyclically:
251251

252-
![Retain cycles](native-retain-cycle.png){height=200}
252+
```mermaid
253+
graph TD
254+
A --> B
255+
B --> C
256+
C --> A
257+
```
253258

254259
Kotlin's tracing GC and Objective-C's ARC handle retain cycles differently. When objects become unreachable, Kotlin's GC
255260
can properly reclaim such cycles, while Objective-C's ARC cannot. Therefore, retain cycles of Kotlin objects can be reclaimed,
256261
while [retain cycles of Swift/Objective-C objects cannot](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/automaticreferencecounting/#Strong-Reference-Cycles-Between-Class-Instances).
257262

258263
Consider the case when a retain cycle contains both Objective-C and Kotlin objects:
259264

260-
![Retain cycles with Objective-C and Kotlin objects](native-objc-kotlin-retain-cycles.png){height=150}
265+
```mermaid
266+
graph TD
267+
Kotlin.A --> ObjC.B
268+
ObjC.B --> Kotlin.A
269+
```
261270

262271
This involves combining Kotlin's and Objective-C's memory management models that cannot handle (reclaim) retain cycles
263272
together. That means if at least one Objective-C object is present, the retain cycle of a whole graph of objects

docs/topics/native/native-get-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ The application prints "Hello, Kotlin/Native" to the standard output.
376376

377377
## What's next?
378378

379-
* Complete the [Create an app using C Interop and libcurl](native-app-with-c-and-libcurl.md) tutorial that explains how
379+
* Complete the [Create an app using C interop and libcurl](native-app-with-c-and-libcurl.md) tutorial that explains how
380380
to create a native HTTP client and interoperate with C libraries.
381381
* Learn how to [write Gradle build scripts for real-life Kotlin/Native projects](multiplatform-dsl-reference.md).
382382
* Read more about the Gradle build system in the [documentation](gradle.md).

0 commit comments

Comments
 (0)