From: Blake M. <bl...@mc...> - 2011-01-10 19:50:48
|
Greetings, I have a need to be able to delete a package (and presumably free its memory). I ran some tests and found that both CLISP and ABCL return free'd package space (with perhaps some leaks) but SBCL does not. It seems that if you repeatably load a package, use it, and then delete it, you continue to use more and more space. The test files I am using are as follows: (memtest2 must be compiled to run all of the tests) ------------------------------- try.lisp: (defun try1 (n) (do ((i 0 (1+ i))) ((> i n) (gc) (terpri) (room)) (print i) (load "memtest1") (delete-package "MEMTEST1"))) (defun try2 (n) (do ((i 0 (1+ i))) ((> i n) (gc) (terpri) (room)) (print i) (load "memtest2.lisp") (delete-package "MEMTEST2"))) (defun try3 (n) (do ((i 0 (1+ i))) ((> i n) (gc) (terpri) (room)) (print i) (load "memtest2") (delete-package "MEMTEST2"))) ---------------------------------------------- memtest1.lisp: (defpackage "MEMTEST1" (:use "COMMON-LISP")) (in-package "MEMTEST1") (provide "MEMTEST1") (defparameter var1 nil) (defun make-cdr-data (n) (do ((i 0 (1+ i))) ((> i n)) (setq var1 (cons nil var1)))) (make-cdr-data 1000000) ----------------------------------------------------------------------- memtest2.lisp: (defpackage "MEMTEST2" (:use "COMMON-LISP")) (in-package "MEMTEST2") (provide "MEMTEST2") (defmacro make-funs (n) (cons 'progn (loop for i from 1 to n collect `(defun ,(intern (concatenate 'string "FUN" (write-to-string i))) (x y) (+ x y))))) (make-funs 1000) |
From: Nikodemus S. <nik...@ra...> - 2011-02-15 10:28:06
|
On 10 January 2011 21:50, Blake McBride <bl...@mc...> wrote: > I have a need to be able to delete a package (and presumably free its > memory). I ran some tests and found that both CLISP and ABCL return > free'd package space (with perhaps some leaks) but SBCL does not. It > seems that if you repeatably load a package, use it, and then delete > it, you continue to use more and more space. The test files I am > using are as follows: (memtest2 must be compiled to run all of the > tests) Yes. This is a known issue -- the crux is that SBCL stores information about variables, functions, etc. in non-weak global data-structures. Currently there is no supported (or even unsupported but usable) way to completely purge all information associated with a package. The plan (absent time to implement it) is to associate the information now stored in the global data-structures with the relevant symbols instead. Cheers, -- Nikodemus |