[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: garbage collection
From: |
Elmar Haneke |
Subject: |
Re: garbage collection |
Date: |
Wed, 26 May 2004 08:32:40 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.6) Gecko/20040413 Debian/1.6-5 |
(2) How much of a problem is this in practice? What kind of programming
constructs lead to running out of memory?
You easyly can run out of space or allocate lots of memory on large jobs.
I yust did an small test on prime number calculation, the executable
produced by gprolog dod allocate 17times more memory than the
equivalent algorithm compiled with "Mercury" which uses (besides other
options) the Boehm Collector.
Elmar
======================= primes.pl ================================
extract([H|Tail1],Div,Tail2):-
0 is H mod Div,
extract(Tail1,Div,Tail2).
extract([H|Tail1],Div,[H|Tail2]):-
H mod Div > 0,
extract(Tail1,Div,Tail2).
extract([],_,[]).
sieve([H|Tail],[H|List]):-
extract(Tail,H,L),
sieve(L,List).
sieve([],[]).
numbers(Max,Max,[Max]).
numbers(Min,Max,[Min|List]):-
Min<Max,
Min2 is Min+1,
numbers(Min2,Max,List).
prime_numbers(Max,List) :-
numbers(2,Max,All),
sieve(All,List).
q :- print('start'),nl,
prime_numbers(60000,X),
length(X,L),write(L),nl
.
:- initialization(q).
===================== execute ===========================
/usr/bin/time -v ./m_primes
6057
Command being timed: "./m_primes"
User time (seconds): 1.96
System time (seconds): 0.06
Percent of CPU this job got: 82%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:02.47
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 0
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 2205
Voluntary context switches: 1
Involuntary context switches: 3582
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
address@hidden:~/mydata/mercury$ /usr/bin/time -v ./p_primes
start
6057
Command being timed: "./p_primes"
User time (seconds): 6.48
System time (seconds): 0.15
Percent of CPU this job got: 94%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:07.06
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 0
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 117
Minor (reclaiming a frame) page faults: 37318
Voluntary context switches: 120
Involuntary context switches: 2120
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: garbage collection,
Elmar Haneke <=