# Object lifetime problem with CxxWrap and make\_const\_array

**URL:** <https://discourse.julialang.org/t/object-lifetime-problem-with-cxxwrap-and-make-const-array/40991>\
**Category:** General Usage\
**Tags:** cxx\
**Created:** [June 8, 2020, 1:42pm UTC](https://discourse.julialang.org/t/object-lifetime-problem-with-cxxwrap-and-make-const-array/40991 "2020-06-08T13:42:42Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![barche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barche/32/79_2.png) [@barche](https://discourse.julialang.org/u/barche)\
**Post date:** [July 3, 2020, 9:38am UTC](https://discourse.julialang.org/t/object-lifetime-problem-with-cxxwrap-and-make-const-array/40991/3 "2020-07-03T09:38:37Z")

</div>

Sorry, just saw this now. To make sure this is related to object lifetime, you could try running it without the garbage collector (`GC.enable(false)`).

Reading [this thread](https://discourse.julialang.org/t/on-the-garbage-collection/35695) I think you might need to use `GC.@preserve` in the line that defines `sqvals`, it seems the compiler might think here that `brv` is no longer needed.

---

_[View the full topic](https://discourse.julialang.org/t/object-lifetime-problem-with-cxxwrap-and-make-const-array/40991)._
