From: Akshay S. <aks...@gm...> - 2012-02-23 14:50:09
|
Hello, I was just fiddling around with SBCL and the garbage collection behavior seemed rather odd to me. Doing: ---------------------------------------------------------------------------------------------------------------------- * (defvar y (make-array 100000000 :element-type 'double-float :initial-element pi)) y * (setq y 0d0) 0d0 * (defvar x (make-array 100000000 :element-type 'double-float :initial-element pi)) --------------------------------------------------------------------------------------------------- or ---------------------------------------------------------------------------------------------------------------------- * (defvar y (make-array 100000000 :element-type 'double-float :initial-element pi)) y * (setq y 0d0) 0d0 * (let ((x (make-array 100000000 :element-type 'double-float :initial-element pi))) (aref x 10)) ---------------------------------------------------------------------------------------------------- makes SBCL complain about stack-size limitation. Doing a (gc :full t) before the second allocation does not help either. The memory usage does not come down after allocating the big array the first time. However this works (no memory complaints): ----------------------------------------------------------------------------------------------- * (let ((y (make-array 100000000 :element-type 'double-float :initial-element pi))) (aref y 10)) 3.14156... * (let ((x (make-array 100000000 :element-type 'double-float :initial-element pi))) (aref x 10)) 3.14156 ------------------------------------------------------------------------------------------------- but this one complains about memory: ----------------------------------------------------------------------------------------------- * (let ((y (make-array 100000000 :element-type 'double-float :initial-element pi))) (aref y 10)) 3.14156... * (defvar x (make-array 100000000 :element-type 'double-float :initial-element pi)) ------------------------------------------------------------------------------------------------- (gc :full t) gets rid of all unused memory when called in cases where the big array was allocated with local scope (inside the let). I can't find documentation about this on google (other than an unsolved post on comp.lang.lisp). Can someone help me as to what is going on ? Thanks, Akshay |