?- findall(N,for_nd(1,100000,N),L).
Bartek can add three 0's to the 100000 in the query if he
so wants.
Again, I think you have not tried with gprolog. With a default GLOBALSZ
of 8 Mb it consumes all the stack with a Stop=1000000 either putting a
variable or the _ as the last findall argument. This may have different
explanations, but I suspect the temporary argument being never freed.
This is supported by:
findall([N,N,N,N,N,N,N,N,N], for_nd(1, 100000, N), _).
doing the same job of consuming the stack. In this case Stop was scaled
down of a factor of 10 and the item size was multiplied by 9. Add the
little overhead of generating a list each iteration and you get the same
memory consumption.
This does not surprise me. As I told you before, this happens also with
your factorial_nd and would happen with any other large, not empty
(probably) loop.