# Borrow checker with GC fallback?

**URL:** <https://discourse.julialang.org/t/borrow-checker-with-gc-fallback/111798>\
**Category:** Internals & Design\
**Created:** [March 19, 2024, 3:21am UTC](https://discourse.julialang.org/t/borrow-checker-with-gc-fallback/111798 "2024-03-19T03:21:18Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [March 19, 2024, 2:20pm UTC](https://discourse.julialang.org/t/borrow-checker-with-gc-fallback/111798/4 "2024-03-19T14:20:04Z")

</div>

See the example I gave here:

> [@Eager finalization and smart pointers](https://discourse.julialang.org/t/eager-finalization-and-smart-pointers/92462/5):
>
> This simplified example looks promising. julia\> n::Int = 0 0 julia\> const safe\_free = Base.@assume\_effects :nothrow :notaskstate x-\>(global n += 1;Libc.free(x.ptr)) #3 (generic function with 1 method) julia\> mutable struct SafePointer ptr::Ptr{Int} end julia\> function f() for i in 1:100 s = SafePointer(Libc.malloc(sizeof(Int))) finalizer(safe\_free, s) end nothing end f (generic function with 1 method) ju…

---

_[View the full topic](https://discourse.julialang.org/t/borrow-checker-with-gc-fallback/111798)._
