Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!amdcad!ames!mailrus!cornell!uw-beaver!ubc-cs!grads.cs.ubc.ca!kean From: kean@grads.cs.ubc.ca (Alex Kean) Newsgroups: comp.lang.prolog Subject: Quintus Prolog Memory Management Message-ID: <3@ubc-cs.UUCP> Date: 17 Nov 88 00:15:16 GMT References: <818@etive.ed.ac.uk> <687@quintus.UUCP> <7919@megaron.arizona.edu> Sender: news@cs.ubc.ca Reply-To: kean@grads.cs.ubc.ca (Alex Kean) Organization: UBC Department of Computer Science, Vancouver, B.C., Canada Lines: 39 I was attempting to run a Quintus Prolog program that potentially generates exponential number of clauses on the inputs. In my case, my set of clauses are roughly 200 where each clause is about 5 literals. They are represented by a list of lists. Unfortunately I ran into [segmentation fault] on a Sun4, SunOS 3.2. I suspected there is some problem with the memory management. I decided to test the memory by writing the following simple program: (1) an outer "loop" that run for "N" times; (2) an inner loop that mutiply a list of 10 chars ['1234567890'] for 18 times and never returns the list. By calling "loop(300)" on the Sun4, the program crash and exits Quintus Prolog. Questions: (a) Which stack has overflowed ? (b) In general, what are the factors to observe when writing prolog programs that takes up lots of memory. ------------------------------------------------------------------------- pair(0,_). pair(N,X) :- append(X,X,Z1), N1 is N - 1, pair(N1,Z1). loop(0). loop(N) :- pair(18,['0123456789']), !, garbage_collect, J is N -1, loop(J). ------------------------------------------------------------------------- Thanks. Alex Kean Department of Computer Science University of British Columbia Vancouver, British Columbia, Canada.