For anyone following, the solution I went with was to instead define the constructor for these special C structs straight in Julia, instead of using those in C, and allocate in Julia via @ccall jl_malloc. This now doesn’t have Julia’s memory usage blow up.
1 Like