Ahoy
I saw this problem discussed before without a resolution. Here is a short test
program:
(defclass user ()
((name :initarg :name :accessor name)
(email :initarg :email :reader user-email)
(email-confirmation-secret :initform ()
:accessor user-email-confirmation-secret)
(email-confirmed-p :initform nil :initarg :email-confirmed-p
:accessor user-email-confirmed-p)
(creation-time :initform (get-universal-time) :reader creation-time)
(trusters :initform nil
:initarg :trusters
:accessor users-who-trust
:documentation "Other users who declared a certain degree
of trust in this user.")
(declared-trusts :initform (make-hash-table) :accessor user-declared-trusts)
(trusts :initform (make-hash-table) :accessor user-trusts)
(debts :initform () :accessor user-debts)))
(defvar *users* ())
(defun test ()
(dotimes (i 1000000)
(when (zerop (mod i 1000))
(print i))
(push (make-instance 'user)
*users*)))
Running (test) sooner or later crashes cmucl:
...
118000
; [GC threshold exceeded with 354,405,552 bytes in use. Commencing GC.]
!!! CMUCL has run out of dynamic heap space. You can control heap size
!!! with the -dynamic-space-size commandline option.
*A2 gc_alloc_large failed, nbytes=536.
Generation Boxed Unboxed LB LUB Alloc Waste Trig WP GCs Mem-age
0: 0 0 0 0 0 0 2000000 0 0 0.0000
1: 0 0 0 0 0 0 2000000 0 0 0.0000
2: 39837 50365 0 0 354145656 15321736 2000000 0 0
0.9974
3: 0 0 0 0 0 0 2000000 0 0 0.0000
4: 0 0 0 0 0 0 2000000 0 0 0.0000
5: 0 0 0 0 0 0 2000000 0 0 0.0000
6: 19864 21006 0 0 160781952 6621568 0 0 0
0.0000
Total bytes alloc=514927608
Maybe the memory is exhausted by a 118000 user instances? Not likely. Now
modify TEST to create as many instances as possible without crashing the
system, say 110000 and invoke gc manually afterwards:
109000
NIL
* (gc)
; [GC threshold exceeded with 326,800,368 bytes in use. Commencing GC.]
!!! CMUCL has run out of dynamic heap space. You can control heap size
!!! with the -dynamic-space-size commandline option.
*A2 gc_alloc_large failed, nbytes=536.
Generation Boxed Unboxed LB LUB Alloc Waste Trig WP GCs Mem-age
0: 0 0 0 0 0 0 2000000 0 0 0.0000
1: 0 0 0 0 0 0 2000000 0 0 0.0000
2: 36646 46444 0 0 326654488 13682152 2000000 0 0
1.0813
3: 0 0 0 0 0 0 2000000 0 0 0.0000
4: 0 0 0 0 0 0 2000000 0 0 0.0000
5: 0 0 0 0 0 0 2000000 0 0 0.0000
6: 22485 25497 0 0 188449560 8084712 0 0 0
0.0000
Total bytes alloc=515104048
This is with 18e-9 on Debian testing/x86. SBCL behaves similarly.
Gabor