diff options
-rw-r--r-- | chickadee/array-list.scm | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/chickadee/array-list.scm b/chickadee/array-list.scm index 54a11e8..3b11ec1 100644 --- a/chickadee/array-list.scm +++ b/chickadee/array-list.scm @@ -93,10 +93,19 @@ (define (array-list-pop! array-list) (let* ((index (1- (array-list-size array-list))) (item (array-list-ref array-list index))) + ;; Remove element reference so it can be GC'd. + (array-list-set! array-list index #f) (set-array-list-size! array-list index) item)) (define (array-list-clear! array-list) + (let ((size (array-list-size array-list)) + (vec (array-list-vector array-list))) + ;; Remove all element references so they can be GC'd. + (let loop ((i 0)) + (when (< i size) + (vector-set! vec i #f) + (loop (1+ i))))) (set-array-list-size! array-list 0) *unspecified*) |