[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Calling a function when a something is garbage collected.
From: |
Grégory Vanuxem |
Subject: |
Calling a function when a something is garbage collected. |
Date: |
Thu, 1 Feb 2024 20:07:48 +0100 |
Hello,
My question is in object, when the garbage collector releases memory
from a variable for example does GCL allow 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:
; TODO: add Clozure CL 'terminate'
(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))
And another question, where can I find documentation for calling C
from GCL Common Lisp?
Regards,
- Greg
- Calling a function when a something is garbage collected.,
Grégory Vanuxem <=