<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 20, 2024, at 11:28 AM, Tim McNerney <<a href="mailto:mc@media.mit.edu" class="">mc@media.mit.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class="">My question had more to do with is the CL GC even <i class="">allowed</i> to call back into Lisp code during collection?</div></div></blockquote><div><br class=""></div><div>Of course.  What would be the point otherwise?  But I think what you really meant to ask is whether finalization methods are allowed to allocate memory.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class="">Impressive that CCL has these advanced GC hooks. I stick by my admonition never to call <b class="">make-instance</b> inside <b class="">finalize</b>.</div></div></div></blockquote><div><br class=""></div><div>Avoiding memory allocation in general inside a finalize method is probably good advice.  But here's a fun experiment:</div><div><div><br class=""></div><div><div><br class=""></div><div>(defclass foo () ())</div><div><br class=""></div><div>(defvar *cnt* 0)</div><div><br class=""></div><div>(defmethod ccl::terminate ((f foo)) ()</div><div>  (incf *cnt*)</div><div>  (terminate-when-unreachable (make-instance 'foo))</div><div>  (terminate-when-unreachable (make-instance 'foo)))</div><div><br class=""></div><div>(terminate-when-unreachable (make-instance 'foo))</div><div class=""><br class=""></div><div class="">(loop (gc) (print *cnt*) (finish-output) (sleep 0.1))</div></div></div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div>Be sure all your files are saved before running this code.</div><div><br class=""></div><div>rg</div><div><br class=""></div></div></body></html>