It feels like you are edging (cc @mbauman) your way towards a reference counting system (Reference counting - Wikipedia). That is indeed a way of doing automatic memory management and it has the advantage that clean up happens as soon as you can no longer reference something. It has some other problems though, in general worse throughput performance than the GC strategy Julia uses and you can end up with cycles of references that are not freed.
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Is my understanding of Julia correct? | 38 | 4673 | March 8, 2022 | |
| Feature request: unsafe_free! | 25 | 1477 | March 21, 2024 | |
| Julia vs Microsoft's (Rust-inspired) Verona language and e.g. snmalloc allocator | 13 | 3691 | May 9, 2020 | |
| Julia GC, heap fragmentation, out of memory, push!/append! | 30 | 2909 | May 20, 2024 | |
| Toward a real and final solution to Julia’s variable scope issue | 37 | 2552 | June 8, 2023 |