# How to use \`GC\_PUSH\` macros

**URL:** https://discourse.julialang.org/t/how-to-use-gc-push-macros/14304
**Category:** New to Julia
**Created:** [August 30, 2018, 11:09am UTC](https://discourse.julialang.org/t/how-to-use-gc-push-macros/14304 "2018-08-30T11:09:23Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [August 30, 2018, 12:20pm UTC](https://discourse.julialang.org/t/how-to-use-gc-push-macros/14304/2 "2018-08-30T12:20:00Z")

</div>

I may be wrong, but I suspect that your GC protection comes too late; the value pointed to by `fn` might get garbage collected while you do `jl_eval_string` for `arg1`, and so on. Try

```julia
    {
      jl_value_t *fn = 0;
      jl_value_t *arg1 = 0;
      jl_value_t *arg2 = 0;
      JL_GC_PUSH3(&fn, &arg1, &arg2);
      fn = jl_eval_string("+");
      arg1 = jl_eval_string("MVector(5., 8., 1.2)");
      arg2 = jl_eval_string("MVector(7., 1., 1.6)");
      res = jl_call2(fn, arg1, arg2);
      JL_GC_POP();
    }

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-use-gc-push-macros/14304)._
