# Memory management and PackageCompiler libraries

**URL:** <https://discourse.julialang.org/t/memory-management-and-packagecompiler-libraries/72980>\
**Category:** General Usage\
**Tags:** embedding, memory, package-compiler\
**Created:** [December 12, 2021, 3:12pm UTC](https://discourse.julialang.org/t/memory-management-and-packagecompiler-libraries/72980 "2021-12-12T15:12:15Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![originalsouth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/originalsouth/32/32061_2.png) [@originalsouth](https://discourse.julialang.org/u/originalsouth)\
**Post date:** [December 13, 2021, 11:37am UTC](https://discourse.julialang.org/t/memory-management-and-packagecompiler-libraries/72980/4 "2021-12-13T11:37:32Z")

</div>

Thanks! A global Set as “root” with a release call, _feels_ wrong but I guess that is the way to go 🙂

Edit: There seems to a similar solution here…

> [@How to keep a reference for C structure to avoid GC?](https://discourse.julialang.org/t/how-to-keep-a-reference-for-c-structure-to-avoid-gc/9310/3):
>
> Don’t use a global dict, that’s not generic and is the slowest possible solution. What you can use depends on how you are calling the C code. A possible solution that should work in most cases is [https://github.com/JuliaPy/PyCall.jl/blob/314ac274326e78f12fbcb73ae0f17f63a3f4bba9/src/pytype.jl#L314](https://github.com/JuliaPy/PyCall.jl/blob/314ac274326e78f12fbcb73ae0f17f63a3f4bba9/src/pytype.jl#L314)

---

_[View the full topic](https://discourse.julialang.org/t/memory-management-and-packagecompiler-libraries/72980)._
