Solving 15Puzzle with Julia
It looks like you store the board after each movement for each possibility, that's a lot of arrays in memory, no wonder it fills your memory
for your second example, your code looks for 157523 positions, which is half of the total possibilities.
the number of permutations for 1:16 is enormous, the a-star algorithm is probably not sufficient
even if you look at only 1% of the total possibilities, you would need hundreds of gigabytes if not terabytes to store them
[6, 5, 4, 1, 7, 3, 9, 8, 2] solved in 26 moves after looking at 157523 positions

julia&gt; using Combinatorics

julia&gt; length(permutations(1:9))
362880

julia&gt; length(permutations(1:16))
20922789888000