Dear list,
Would it be possible to create a class in such a fashion that it could be
GC'd once all its instances are gone?
I've tried creating a class in a couple of ways that I thought would work,
and then installing a finalizer function on it to show if it were GC'd,
but I can't seem to get them to be GC'd whatever I do, even if I hack away
all the references I've been able to find, including the following
obviously ugly ways:
(let ((test-class (defclass foo (transient) ())))
(finalize test-class #'(lambda () (print "foo")))
(setf (sb-kernel:classoid-cell-pcl-class (sb-kernel:find-classoid-cell 'foo)) nil)
(sb-mop:remove-direct-subclass (find-class 'transient) test-class))
(let ((test-class (make-instance 'standard-class
:name 'bar
:direct-superclasses (list (find-class 'transient)))))
(finalize test-class #'(lambda () (print "bar")))
(assert (null (ignore-errors (find-class 'bar))))
(sb-mop:remove-direct-subclass (find-class 'transient) test-class))
I then run (gc :full t), but get printed neither "foo" nor "bar".
Is it *at all* possible to create classes that can be GC'd, and if it is,
can it be done in a way that is not a horribly ugly hack? (Even better,
can it be done in any way that might even work outisde SBCL?)
--
Fredrik Tolf
------------------------------------------------------------------------------
How fast is your code?
3 out of 4 devs don\\\'t know how their code performs in production.
Find out how slow your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219672;13503038;z?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Sbcl-help mailing list
Sbcl...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-help