users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Iteratively calling Prolog from C


From: Daniele Peri
Subject: Re: Iteratively calling Prolog from C
Date: Fri, 18 Jul 2003 10:19:04 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

Daniele Peri wrote:
Daniel Dudley wrote:

Bartek Wilczynski wrote:

?- 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.

I made another a couple of other tests with your predicate:

| ?- for_nd(1, 1000000, N), fail.

Fatal Error: global stack overflow (size: 8192 Kb, environment variable used: GLOBALSZ)

| ?- for_nd(1, 1000000, _), fail.

Fatal Error: global stack overflow (size: 8192 Kb, environment variable used: GLOBALSZ)

Daniele





reply via email to

[Prev in Thread] Current Thread [Next in Thread]