C struct garbage collection not run frequently enough

You have to allocate the memory in Julia and pass a pointer to it to C.
E.g.


mutable struct TheCtype
   x::Cint
end

function do_something(ct::TheCtype)
   p = pointer_from_objref(ct)
   GC.@preserve ct begin
      @ccall my_c_function(p::Ptr{Cvoid})::Cvoid
   end
end