From 51484175dee4b0566b270fd62356b1198afdba22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1ll=20Haraldsson?= Date: Tue, 28 Apr 2020 22:49:14 +0000 Subject: [PATCH] Describe rooting (#32790) * Describe rooting [skip ci] * Modified rooting text with link to root [skip ci] --- doc/src/manual/embedding.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/src/manual/embedding.md b/doc/src/manual/embedding.md index 72d86a960531b..1eb42a693f321 100644 --- a/doc/src/manual/embedding.md +++ b/doc/src/manual/embedding.md @@ -253,8 +253,11 @@ out from under you, rendering pointers invalid. The GC can only run when Julia objects are allocated. Calls like `jl_box_float64` perform allocation, and allocation might also happen at any point in running Julia code. However, it is generally safe to use pointers in between `jl_...` calls. But in order to make sure that values can survive -`jl_...` calls, we have to tell Julia that we hold a reference to a Julia value. This can be done -using the `JL_GC_PUSH` macros: +`jl_...` calls, we have to tell Julia that we still hold a reference to Julia +[root](https://www.cs.purdue.edu/homes/hosking/690M/p611-fenichel.pdf) values, a process +called "GC rooting". Rooting a value will ensure that the garbage collector does not accidentally +identify this value as unused and free the memory backing that value. This can be done using the +`JL_GC_PUSH` macros: ```c jl_value_t *ret = jl_eval_string("sqrt(2.0)");