bug#40194: Weak sets keep growing

Ludovic Courtès <[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <[email protected]>
Hello,

Consider this code:

--8<---------------cut here---------------start------------->8---
(define (create-symbols)
  (let loop ((i 10000))
    (unless (zero? i)
      (gensym)
      (loop (1- i)))))

(let loop ((i 10))
  (unless (zero? i)
    (pk i (%symbols))
    (create-symbols)
    (loop (1- i))))
--8<---------------cut here---------------end--------------->8---

(You need to have the ‘%symbols’ procedure from libguile/symbols.c
compiled in.)

In 3.0.1+, it prints:

--8<---------------cut here---------------start------------->8---
;;; (10 #<weak-set 3517/7027>)

;;; (9 #<weak-set 10271/14051>)

;;; (8 #<weak-set 11625/28099>)

;;; (7 #<weak-set 21625/28099>)

;;; (6 #<weak-set 11090/56197>)

;;; (5 #<weak-set 21090/56197>)

;;; (4 #<weak-set 31090/56197>)

;;; (3 #<weak-set 41090/56197>)

;;; (2 #<weak-set 5052/112363>)

;;; (1 #<weak-set 15052/112363>)
--8<---------------cut here---------------end--------------->8---

The size of the weak set keeps growing, even when GC happens.

Conversely, weak tables shrink upon GC.

Ludo’.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.