C struct garbage collection not run frequently enough

You do not need to link, as julia already is linked against it (it’s probably libjulia, but I haven’t checked). So you can directly use

@ccall jl_malloc(4::Csize_t)::Ptr{Cvoid}

Obviously, you need to replace the 4 by the needed size.