# How to Obtain Efficient Garbage Collection of C-Ptrs

**URL:** <https://discourse.julialang.org/t/how-to-obtain-efficient-garbage-collection-of-c-ptrs/126307>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 25, 2025, 6:39pm UTC](https://discourse.julialang.org/t/how-to-obtain-efficient-garbage-collection-of-c-ptrs/126307 "2025-02-25T18:39:11Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nhz2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nhz2/32/44428_2.png) [@nhz2](https://discourse.julialang.org/u/nhz2)\
**Post date:** [February 25, 2025, 7:08pm UTC](https://discourse.julialang.org/t/how-to-obtain-efficient-garbage-collection-of-c-ptrs/126307/2 "2025-02-25T19:08:17Z")

</div>

I recently fixed a similar issue in [CodecZlib.jl](https://github.com/JuliaIO/CodecZlib.jl/pull/97#discussion_r1943986518) by getting the C library to use `jl_malloc` and `jl_free` instead of `malloc` and `free` Ref: [C struct garbage collection not run frequently enough - #14 by vchuravy](https://discourse.julialang.org/t/c-struct-garbage-collection-not-run-frequently-enough/116919/14)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-obtain-efficient-garbage-collection-of-c-ptrs/126307)._
