Re: debugging memory usage
- From: Bart Demoen <bmd@xxxxxxxxxxxxxx>
- Date: Sun, 15 Jan 2006 21:08:55 +0100
Andrey Rybalchenko wrote:
Dear group,
my sicstus prolog program, which implements some symbolic computations, terminates with the exception resource_error(0,memory). The behavior is reproducible, but takes about 10 hours to do so.
What is the best way to find out where the memory is consumed?
The "best" way might depend on how big your program is: if it not too big, I would do a visual inspection looking for left behind choicepoints, left recursion, and accumulating parameters that keep accumulating during 10 hours. I would also look for creation of new atoms/functors. If you know your program very well, you could do that on a larger program as well.
Another thing you could do: call statistics/0 when you get the exception. Any memory area that has grown will show up there. If you feel unsure about that, try to get out of memory with the following program:
a([X|R]) :-
X = [1,2,3,4,5,6,7,8,9,0,_],
a(R).a :- a, b.
d :- d. d.
once with the query ?- a(_). and once with ?- a. and once with ?- d. and look at the output of statistics/0 and which areas have become big. Compare it to what statistics shows after your own program has run out of memory. You might not have learned very much, but at least you might know whether the overflow is because of term creation, choicepoints or recursion depth.
If the program is not too big, put it on a website so that we can see it.
Tell us about the outcome please :-)
Cheers
Bart Demoen .
- Follow-Ups:
- Re: debugging memory usage
- From: Andrey Rybalchenko
- Re: debugging memory usage
- References:
- debugging memory usage
- From: Andrey Rybalchenko
- debugging memory usage
- Prev by Date: Introductory Prolog textbook
- Next by Date: Re: Introductory Prolog textbook
- Previous by thread: debugging memory usage
- Next by thread: Re: debugging memory usage
- Index(es):
Relevant Pages
|
|