I am trying to generate combinations of integers in the range from 1 to 12. Using 8 as an argument for the function below I get an OutOfMemory() error. The function works as expected for N < 8. My PC has 32GB of memory of which only 31% is being used. Since binomial(12, 8) == 495
the number of items is small and so is the space occupied by each one. What is happening?
function all_combs(n)
m12 = 1:12 |> collect
Base.product(values(repeat([m12], n))...) |> collect |> vec
end
julia> all_combs(8)
ERROR: OutOfMemoryError()
Is there an alternative way to create this array?