Re: Prolog, memory management and memory leaks
- From: Jan Wielemaker <jan@xxxxxxxxxxxxxxxxxxx>
- Date: 30 Jan 2008 12:53:35 GMT
On 2008-01-30, Bart Demoen <bmd@xxxxxxxxxxxxxxxxx> wrote:
Jan Wielemaker wrote:
On 2008-01-30, Bart Demoen <bmd@xxxxxxxxxxxxxxxxx> wrote:
Joachim Schimpf wrote:
Atoms that occur literally in your code will never be gc'd.
This is not universally true: it seems like those atoms are gc'd
in SWI-Prolog - and they were in BIM-Prolog.
I guess Joachim means with 'literally in your code' that is is part of
the program. Any atom appearing in the program is referenced by some
predicate and will not be GC'ed. I can think of only two exceptions:
abolish the code or do term-expansion such that what is 'literally in
your code' isn't what goes into the Prolog DB :-)
SWI-Prolog does reference-counting on atoms referenced from predicates,
records and foreign code. Atom-gc marks all atoms reachable from the
stacks of all threads.
When I wrote that atoms seem gc'd in SWI even when appearing literally in your code,
I did that based on a small experiment - here is the code:
s(N) :-
N > 0,
open('foo.pl',write,S),
write(S,'foo(asd'), write(S,N), write(S,').'), nl(S),
close(S),
[foo],
M is N - 1,
s(M).
Calling ?- s(10000). results in 10000 programs being consulted, and each of
them has a different atom literally appearing in it - at least to my understanding
of those words. Statistics at the end says:
3,415 atoms, 1,208 functors, 1,388 predicates, 18 modules, 28,935 VM-codes
and
1 atom garbage collections gained 8,520 atoms in 0.00 seconds.
Is that consistent with what any of us has been claiming ?
I think it is consistent with all views. Joachim probably claims that
`litterally in your code' only applies to the last version you loaded.
You are right that at some point it was literally in the code and I am
right because reloading the same file abolishes the old definitions in
SWI-Prolog.
We are all happy :-)
I also think reloading files for anything but development purposes is
a bad habbit, so I think a Prolog system that keeps these atoms (or
even the 10,000 clauses) around is equally acceptable.
--- Jan
.
- Follow-Ups:
- Re: Prolog, memory management and memory leaks
- From: bart demoen
- Re: Prolog, memory management and memory leaks
- References:
- Prolog, memory management and memory leaks
- From: A . L .
- Re: Prolog, memory management and memory leaks
- From: bart demoen
- Re: Prolog, memory management and memory leaks
- From: Mats
- Re: Prolog, memory management and memory leaks
- From: Jan Wielemaker
- Re: Prolog, memory management and memory leaks
- From: A . L .
- Re: Prolog, memory management and memory leaks
- From: Joachim Schimpf
- Re: Prolog, memory management and memory leaks
- From: Bart Demoen
- Re: Prolog, memory management and memory leaks
- From: Jan Wielemaker
- Re: Prolog, memory management and memory leaks
- From: Bart Demoen
- Prolog, memory management and memory leaks
- Prev by Date: Re: Prolog, memory management and memory leaks
- Next by Date: Re: Prolog, memory management and memory leaks
- Previous by thread: Re: Prolog, memory management and memory leaks
- Next by thread: Re: Prolog, memory management and memory leaks
- Index(es):