# \#finalization

**URL:** https://discourse.julialang.org/tag/finalization/1449.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Example of registering a finalizer for unsafe\_wrapped data from ccall](https://discourse.julialang.org/t/example-of-registering-a-finalizer-for-unsafe-wrapped-data-from-ccall/122499)

<div class="topic-metadata">

**Author:** [@gmcardle](https://discourse.julialang.org/u/gmcardle)\
**Replies:** 9\
**Last updated:** [November 12, 2024, 2:49pm UTC](https://discourse.julialang.org/t/example-of-registering-a-finalizer-for-unsafe-wrapped-data-from-ccall/122499 "2024-11-12T14:49:55Z")

</div>

Hi, I’m using ccall on a C library that returns a pointer to some data that was malloced in the library and requires a separate API call to close the resource that the data came from. The dataset could be quite large (a …

---

## [Can calling finalize lead to a double free?](https://discourse.julialang.org/t/can-calling-finalize-lead-to-a-double-free/116612)

<div class="topic-metadata">

**Author:** [@nhz2](https://discourse.julialang.org/u/nhz2)\
**Replies:** 4\
**Last updated:** [July 4, 2024, 10:44am UTC](https://discourse.julialang.org/t/can-calling-finalize-lead-to-a-double-free/116612 "2024-07-04T10:44:55Z")

</div>

Are finalizers guaranteed to only run at most one time? Is there any way for a finalizer to somehow get called twice, for example, if finalize is called in multiple other finalizers, or manually called in different threa…

---

## [Do-Block Syntax with Where Keyword](https://discourse.julialang.org/t/do-block-syntax-with-where-keyword/115131)

<div class="topic-metadata">

**Author:** [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Replies:** 16\
**Last updated:** [June 7, 2024, 6:46am UTC](https://discourse.julialang.org/t/do-block-syntax-with-where-keyword/115131 "2024-06-07T06:46:28Z")

</div>

I want to use a finalizer for a parametric type using the type parameter in the finalizer. I have a solution for that, but I wondered whether I can use the do syntax, but I simply do not know where the where needs to be …

---

## [My julia code has segfault only on exit - is there a way to simply stop julia without calling into this finalization stuff](https://discourse.julialang.org/t/my-julia-code-has-segfault-only-on-exit-is-there-a-way-to-simply-stop-julia-without-calling-into-this-finalization-stuff/106538)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 1\
**Last updated:** [November 22, 2023, 7:08am UTC](https://discourse.julialang.org/t/my-julia-code-has-segfault-only-on-exit-is-there-a-way-to-simply-stop-julia-without-calling-into-this-finalization-stuff/106538 "2023-11-22T07:08:40Z")

</div>

I just opened an issue for a segmentation fault with RCall which only happens on exit I would like to find a workaround, i.e. somehow kill Julia without running into those finalizers which cause segmentation fault. It…

---

## [Can I mimick finalizing for immutables / is an immutable file handler unfeasible?](https://discourse.julialang.org/t/can-i-mimick-finalizing-for-immutables-is-an-immutable-file-handler-unfeasible/104687)

<div class="topic-metadata">

**Author:** [@Benny](https://discourse.julialang.org/u/Benny)\
**Replies:** 16\
**Last updated:** [October 15, 2023, 9:30am UTC](https://discourse.julialang.org/t/can-i-mimick-finalizing-for-immutables-is-an-immutable-file-handler-unfeasible/104687 "2023-10-15T09:30:20Z")

</div>

I can’t think of other uses for destructors/finalizers in a language without manual deallocations, so I’m using file-closing as an example. It seems to me that I could implement open to open a file and construct an immut…
