Lisp HUG Maillist Archive

Are compiled functions collected?

Just curious, if I do:

CL-USER > (setf foo (compile nil '(lambda () 'foo)))
#<Function 424 200A71E2>

CL-USER > (setf foo 10)
10

Will the function I compiled eventually be collected? I understand this 
might be implementation dependent. But, since LW is the only Lisp I 
use... ;-)

Thanks!

Jeff M.

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Are compiled functions collected?


* Jeffrey Massung <52117C04.4060102@gmail.com> :
Wrote on Sun, 18 Aug 2013 20:59:32 -0500:

| CL-USER > (setf foo (compile nil '(lambda () 'foo)))
| #<Function 424 200A71E2>
|
| CL-USER > (setf foo 10)
| 10
|
| Will the function I compiled eventually be collected? I understand
| this might be implementation dependent. But, since LW is the only Lisp
| I use... ;-)

I believe it would, given that this *is* LW, after all.  And much as I
would like to study LW GC code, the following simple test shows an
explicit gc-all would collect them, and gives me confidence that this
works as expected. ---Regards, Madhu


(progn (gc-all) (room))
(defvar $syms nil)

(time
 (loop repeat 15 for sym = (gensym)
      do (set sym (compile nil `(lambda ()
				  ,(make-string (expt 2 21)
						:initial-element
						(code-char (random 256))))))
      (push sym $syms)))

#+nil
(length (funcall  (symbol-value (elt $syms 2))))

(progn (gc-all) (room))
(mapcar (lambda (sym) (set sym 10)) $syms)
(progn (gc-all) (room))

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: Are compiled functions collected?

Unable to parse email body. Email id is 12399

Updated at: 2020-12-10 08:35 UTC