Hi, I have a question about memory management In t...
# kotlin-native
t
Hi, I have a question about memory management In the source of the Kotlin Runtime, inside Memory.cpp (https://github.com/JetBrains/kotlin-native/blob/20d3e12e7cdc60af02d7e7c4620f4b577b1141c8/runtime/src/main/cpp/Memory.cpp) I found this:
Copy code
// If garbage collection algorithm for cyclic garbage to be used.
// We are using the Bacon's algorithm for GC, see
// <http://researcher.watson.ibm.com/researcher/files/us-bacon/Bacon03Pure.pdf>.
#define USE_GC 1
Does this define control all GC behaviour? If I set it to zero have I achieved manual memory management in all cases? Is there an easy to control option for this in any IDE that supports Kotlin or do I have to build my own runtime with the option set the way I want and then manually bind that runtime to my project?
n
Kotlin Native's uses ARC (Automatic Resource Collector) for memory management ( https://github.com/JetBrains/kotlin-native/blob/master/FAQ.md#q-what-is-kotlinnative-memory-management-model ). What you are looking at is the cyclic collector that is used in conjunction with ARC.
Turning off the GC will not provide manual memory management. Instead the cyclic collector will be disabled, and you will have to deal with cyclic references manually, which is useful for some situations where there are soft real-time performance requirements.
t
can I turn off the ARC too?