Remove memory from Julia's management

Chrysoberyl
Wed, 19 Nov 2025 08:50:08 +0000
General Usage

When calling into Julia and using it as a library, is it possible to remove an allocated datum from Julia’s management?

My use case is this: I have a Julia function, passed across FFI as a callback, which creates data by calling functions in C, and it needs to return this data out of Julia. When this happens, the memory management obligation of this data is no longer Julia’s.

Alternatively, would it be possible to remove a pointer finalizer on the data? This way, any associated finalizers introduced by the FFI would not get called. I looked at the source code julia/src/gc-common.c at cd2dc914625f1eec549eb32332f1e4c4f0406152 · JuliaLang/julia · GitHub and it would not be too difficult to write such a function.

3 posts - 3 participants