[Openmcl-devel] Calling a function when memory is garbage collected.
Michał "phoe" Herda
phoe at disroot.org
Thu Feb 1 11:45:54 PST 2024
See https://ccl.clozure.com/manual/chapter13.11.html
See
https://github.com/trivial-garbage/trivial-garbage/blob/3474f6414b73d4e3aa2d5c53080f4247a34f6380/trivial-garbage.lisp#L386-L392
W dniu 2024-02-01 20:40, Grégory Vanuxem napisał(a):
> Hello,
>
> My question is in object, when the garbage collector releases memory
> from a variable for example does Clozure CL allow the user to add a
> "hook" function to do some other things? Namely I also need to release
> memory in another place not known to the garbage collector. Here is a
> piece of code for
> other CL implementations:
>
> (defun make_jlref (val type)
> (let* ((ret (make-instance 'jlref :val val :type type))
> (hash (write-to-string (sxhash ret) :base 16)))
> #+:lispworks (flag-special-free-action hash)
> #+:cmu (ext:finalize ret (lambda () (free_jlref hash)))
> #+:sbcl (sb-ext:finalize ret (lambda () (free_jlref hash)))
> #+:allegro (excl:schedule-finalization ret (lambda ()
> (free_jlref hash)))
> (setf (jlrefId ret) hash)
> ret))
>
> Regards,
> - Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20240201/5fbff2b6/attachment.htm>
More information about the Openmcl-devel
mailing list