Re: Prolog, memory management and memory leaks
- From: Jan Wielemaker <jan@xxxxxxxxxxxxxxxxxxx>
- Date: 29 Jan 2008 13:13:11 GMT
On 2008-01-29, Mats <matsc@xxxxxxx> wrote:
In my experience, a more difficult kind of "memory leak" is memory
fragmentation. Many Prolog implementations manage their own memory;
others rely on malloc & free or similar. In both cases, memory can
easily become fragmented when the process has run for a long while,
filling the memory with blocks that are too small to be useful. Some
memory managers (SICStus's for example) coalesce adjacent free blocks
as far as possible, but I'm not aware of any Prolog that move blocks
around and completely defragment memory, which would be extremely
complex, what with all the necessary relocation and everything. The
only safe cure I know of is to restart the process.
This is indeed a problem I have seen, though Prolog isn't the only
language suffering. In fact, Prolog may not be that bad as lots of
things are allocated on the stacks and these are nicely compacted.
One does need to be careful with dynamic code, records and atoms
though. Dynamic code might often not be that bad as quite often it
uses asserts and retracts clauses of the same structure that happen to
result in a perfect match. Atoms are a bigger problem, especially if
code uses lots of long atoms (SWI-Prolog has no limit except for
available memory).
Many programs that run 24x7 execute a limited set of similar routines
frequently and for them memory often stops growing after a while.
--- Jan
.
- Follow-Ups:
- Re: Prolog, memory management and memory leaks
- From: A . L .
- 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
- 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):
Relevant Pages
|
|