There is not enough given for me to recreate the problem.
For instance, what happens in num_origin_1d_fix
is not known. It is always easiest to track down a problem when the context (lines of code) has been stripped down as much as possible, while still triggering the error.
Just guessing, your out of memory error may happen because there is something that could be better structured internally – leaking a great deal of memory inadvertantly is not usually a problem with Julia code; however you may be generating many copies of arrays for which only one or a few are utilized. And it is certainly possible that you have created dependencies among some chain[s] of them that is preventing the Garbage Collector from culling. Alternatively, you may be spawning many more threads than intended or requiring each to have very large local memory. This is all speculation, though.