I figured, I can use @spawnat but have to make b a global variable, so it is accessible outside of the function scope. I’m still curios why @everywhere combined with a specific worker allocation uses so much memory.
using Distributed
addprocs(2)
# initialize function on worker
@everywhere begin
testFunc(b) = b * 2
end
# initialize local variable on each worker
w = []
for x in workers()
ini = @spawnat x begin
global b = myid()
end
push!(w, ini)
end
wait.(w)
# call function on worker
fetch(Distributed.@spawnat 3 testFunc(b))