(+ (dynamic-usage)
*n-bytes-freed-or-purified*))
\f
-;;;; variables and constants
-
-;;; the minimum amount of dynamic space which must be consed before a
-;;; GC will be triggered
-;;;
-;;; Unlike CMU CL, we don't export this variable. (There's no need to,
-;;; since our BYTES-CONSED-BETWEEN-GCS function is SETFable.)
-(defvar *bytes-consed-between-gcs*
- #!+gencgc (* 4 (expt 10 6))
- ;; Stop-and-copy GC is really really slow when used too often. CSR
- ;; reported that even on his old 64 Mb SPARC, 20 Mb is much faster
- ;; than 4 Mb when rebuilding SBCL ca. 0.7.1. For modern machines
- ;; with >> 128 Mb memory, the optimum could be significantly more
- ;; than this, but at least 20 Mb should be better than 4 Mb.
- #!-gencgc (* 20 (expt 10 6)))
-(declaim (type index *bytes-consed-between-gcs*))
-
;;;; GC hooks
(defvar *before-gc-hooks* nil ; actually initialized in cold init
;;; For GENCGC all generations < GEN will be GC'ed.
#!+sb-thread
-(defun sub-gc (&key (gen 0))
+(defun sub-gc (&key (gen 0) &aux (pre-gc-dynamic-usage (dynamic-usage)))
(setf *need-to-collect-garbage* t)
(when (zerop *gc-inhibit*)
(setf (sb!alien:extern-alien "maybe_gc_pending" (sb!alien:unsigned 32))
(when (zerop
(sb!alien:extern-alien "maybe_gc_pending" (sb!alien:unsigned 32)))
(return nil)))
+ (incf *n-bytes-freed-or-purified*
+ (max 0 (- pre-gc-dynamic-usage (dynamic-usage))))
(setf *need-to-collect-garbage* nil)
(scrub-control-stack))
(values))
#!-sb-thread
(defvar *already-in-gc* nil "System is running SUB-GC")
#!-sb-thread
-(defun sub-gc (&key (gen 0))
+(defun sub-gc (&key (gen 0) &aux (pre-gc-dynamic-usage (dynamic-usage)))
(when *already-in-gc* (return-from sub-gc nil))
(setf *need-to-collect-garbage* t)
(when (zerop *gc-inhibit*)
(let ((*already-in-gc* t))
(without-interrupts (collect-garbage gen))
+ (incf *n-bytes-freed-or-purified*
+ (max 0 (- pre-gc-dynamic-usage (dynamic-usage))))
(setf *need-to-collect-garbage* nil))
(scrub-control-stack))
(values))
#!+(and sb-doc (not gencgc))
"Initiate a garbage collection. GEN may be provided for compatibility with
generational garbage collectors, but is ignored in this implementation."
- (sub-gc :gen (if full 6 gen)))
+ (sub-gc :gen (if full 6 gen)))
\f
;;;; auxiliary functions