[Openmcl-devel] SOLVED: Was Garbage collector - ccl:terminate (memory stuff)

Grégory Vanuxem g.vanuxem at gmail.com
Fri May 31 19:47:50 PDT 2024


Hello Matthew, *,

Le ven. 31 mai 2024 à 20:33, R. Matthew Emerson <rme at clozure.com> a écrit :
>
>
>
> > On May 22, 2024, at 2:22 PM, Grégory Vanuxem <g.vanuxem at gmail.com> wrote:
> >
> > Hi Robert, hi all,
> >
> > Many thanks for your reply. It allowed me to go further into this and
> > I have found a solution.
> >
> > In the FriCAS context, the email, I just sent to the FriCAS mailing list:
> > https://groups.google.com/g/fricas-devel/c/kHMffXyMIB0/m/hMh1mMasBQAJ
> >
> > Basically FriCAS create a simple fricas-class application:
> >
> > (defclass fricas-application (ccl::application) ())
>
> It looks a bit odd that you are inheriting from ccl::application here, yet in your toplevel-function method below, you create an instance of ccl::lisp-development-system.  I’m somewhat surprised that works for you.

It is not my code. It was inspired by old code from what I know. Since
then Clozure CL has evolved.

> >
> > and use it at startup:
> >
> > (defmethod ccl::toplevel-function ((app fricas-application) init-file)
> > [snippet]
> >        (funcall *my-toplevel-function*)
> >        (let ((ap (make-instance 'ccl::lisp-development-system)))
> >            (ccl::toplevel-function ap init-file)))
> >
> > And, basically, the fricas-application (FiCAS) when
> >
> >       (CCL::save-application core-image
> >                                      :PREPEND-KERNEL t
> >                                      :application-class 'fricas-application)
> >
> > Does not execute ccl:terminate, you have to return (start) to the
> > "main" thead/process to allow CCL to execute the terminate method.
>
> What does *my-toplevel-function* do?  If it’s just some additional initialization, maybe you could put a :before method on toplevel-function (application t) instead?

It's removed now. The diff is here, sorry I forgot to mention it:

https://github.com/fricas/fricas/commit/188e633ff90e0140d2a15afcd89d8dfa79f95ccb#diff-ef5e3194150e5f7307ca93cf74c3a798b97591d64fa2048330d4760c77e97c87

It's just a lambda form.

I will give it a try, thanks. I find this "issue" a little boring,
having an apparently stalled thread.

> In the method toplevel-function (ccl::lisp-development-system t)
>
> https://github.com/Clozure/ccl/blob/19906f6afdff4dbf232f560a4d13a81da65daf5f/level-1/l1-application.lisp#L284
>
> we start a loop that calls the function called ccl::housekeeping a few times a second.  One of the housekeeping tasks is to run gc hook functions.  (The hook functions are managed via ccl::add-gc-hook and ccl::remove-gc-hook.)
>
> https://github.com/Clozure/ccl/blob/19906f6afdff4dbf232f560a4d13a81da65daf5f/level-1/l1-events.lisp#L166
>
> As you may suspect by now, the way termination functions get called is via a gc hook. So, if the housekeeping loop doesn’t run for some reason, then automatic termination won’t work.
>
> If you can’t run the housekeeping loop, I think it would work to call ccl:drain-termination-queue manually as needed.

Very interesting, I have not noticed this.

Best regards,
- Greg


More information about the Openmcl-devel mailing list