Skip to content

Commit

Permalink
Describe rooting (JuliaLang#32790)
Browse files Browse the repository at this point in the history
* Describe rooting

[skip ci]

* Modified rooting text with link to root

[skip ci]
  • Loading branch information
PallHaraldsson committed Apr 28, 2020
1 parent 59afa96 commit 5148417
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions doc/src/manual/embedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
Expand Down

0 comments on commit 5148417

Please sign in to comment.