memory leak loading file multiple times
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Incomplete
|
Undecided
|
Unassigned |
Bug Description
i was trying to load the mnist dataset from a csv file (105mb) into sbcl when i found this frustrating memory leak
#+begin_src lisp
(defun get-file (filename)
(with-open-file (stream filename)
(loop for line = (read-line stream nil)
while line
collect line)))
(loop for j from 0 below 3
do (defparameter a (get-file (pathname "/home/
#+end_src
i ran sbcl with 1gb heap size using ~sbcl --dynamic-
if i load the file only once, it works fine, twice or more it crashes
sbcl would crash with the following error:
#+begin_src lisp
,* Heap exhausted during garbage collection: 3696 bytes available, 7312 requested.
Immobile Object Counts
Gen layout fdefn symbol code Boxed Cons Raw Code SmMix Mixed LgRaw LgCode LgMix Waste% Alloc Trig Dirty GCs Mem-age
1 0 0 0 0 0 26 9762 0 0 6 0 0 0 10.7 286734832 182768138 9794 1 1.4000
2 252 3079 681 2072 82 102 22135 3 12 14 0 0 0 10.5 655347392 2000000 22156 0 1.2896
3 0 0 0 0 0 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 0 0 0.0 0 2000000 0 0 0.0000
5 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0 0 2000000 0 0 0.0000
fatal error encountered in SBCL pid 412660 tid 412660:
GC invariant lost, file "gencgc.c", line 523
Welcome to LDB, a low-level debugger for the Lisp runtime environment.
(GC in progress, oldspace=1, newspace=2)
ldb>
#+end_src
im on arch linux, more info:
#+begin_src bash
~ λ sbcl --version
SBCL 2.3.3
~ λ uname -a
Linux mahmooz 6.1.28-1-lts #1 SMP PREEMPT_DYNAMIC Thu, 11 May 2023 15:52:41 +0000 x86_64 GNU/Linux
#+end_src
also tried on sbcl versions 2.3.4 and 2.3.1, same error
although i did try running the same code in ~clisp~ and it worked flawlessly, and memory usage wasnt even noticable!
thanks in advance
I don't see a leak here, 1GB is not enough to hold 2x the contents of that file at the same time.