I one of my short programs i generated long list of conses (growing
from tail end). Head of list, after some computations, can be dropped.
At the moment I need only last k (k unknown) values from list tail
(in sample code below I keep just 1 cell, previous can be garbaged).
In clisp or ccl this works, sbcl eats all memory and goes to ldb.
(sbcl 1.0.49 on Windows XP and 1.0.3x on Linux - Debian 5)
Code like this:
(defun iter (n)
(let ((seq (cons 1 nil)))
(dotimes (i n)
(let ((new-cons (cons i nil)))
(setf (cdr seq) new-cons)
(setf seq new-cons)
(when (zerop (rem i 1000000))
(format t "n = ~a ~%" i)
;#+sbcl (sb-ext::gc)
)))
(car seq)))
(iter 100000000)
n = 0
n = 1000000
n = 2000000
...
n = 30000000
n = 31000000
n = 32000000
Heap exhausted during garbage collection: 0 bytes available, 8 requested.
Gen StaPg UbSta LaSta LUbSt Boxed Unboxed LB LUB !move Alloc Waste
Trig WP GCs Mem-age
0: 0 0 0 0 0 0 0 0 0 0
0 2000000 0 0 0,0000
1: 0 0 0 0 0 0 0 0 0 0
0 2000000 0 0 0,0000
2: 90243 0 0 0 63636 333 0 0 0 261665144
351880 2000000 0 0 1,1693
3: 0 0 0 0 0 0 0 0 0 0
0 2000000 0 0 0,0000
4: 0 0 0 0 0 0 0 0 0 0
0 2000000 0 0 0,0000
5: 0 0 0 0 0 0 0 0 0 0
0 2000000 0 0 0,0000
6: 0 0 0 0 5507 1151 0 0 0 27271168
0 2000000 5309 0 0,0000
Total bytes allocated = 536315192
Dynamic-space-size bytes = 536870912
GC control variables:
*GC-INHIBIT* = true
*GC-PENDING* = in progress
fatal error encountered in SBCL pid 3532:
Heap exhausted, game over.
Welcome to LDB, a low-level debugger for the Lisp runtime environment.
ldb>
Is it normal behaviour for sbcl GC or it is a bug?
Maybe there are some parameters for GC machinery i can switch?
--
pozdrawiam
Piotr Chamera
|