I have not run your code, but this looks like the issue and explains why passing the fields instead of the struct causes no allocations.
From the perspective of the compiler/type system, your definition means that alternatives and avmap are <: Any and nothing else is communicated. This means at runtime, Julia has to inspect the types of these fields and dispatch at runtime to the proper method.
A quick fix to this would involve parameterizing MyStruct like so:
struct MyStruct{TA,TM}
alternatives::TA
avmap::TM
end
such that Julia could know the types of these fields at compiletime.
The reason your last implementation works so well is that when you pass in the explicit objects, the compiler know the exact types and can compile efficient code without runtime dispatch.