Search code examples
common-lispgnu-common-lisp

Force garbage collection in GCL


I made a program in Maxima(translates it to lisp as it runs on top of lisp) that progressively solves equations. I wanted to show that in case it is not possible that all equations can be loaded in RAM and solved simultaneously, then few of them can be loaded and progressively we can add more and use the solutions from previously solved equations to get more solutions for newly added equations.

My program is working fine. But the problem is that I if I need to show that my approach will save RAM then I need to run GC before new set of equations are solved, so that I can see how minimum memory I am using, while presently compiler doesn't seem to go for GC automatically, hence it shows aggregated memory used for complete operation.

I am using Lisp implementation version: GCL 2.6.8.

I need to know how I can force garbage collection or some more effective approach someone can suggest in case its not possible to force GC in lisp(I couldn't find a way).


Solution

  • Grepping through the manpage of gcl I found the following(is that what you wanted?)

    Function: GBC (x) Package:LISP GCL specific: Invokes the garbage collector (GC) with the collection level specified by X. NIL as the argument causes GC to collect cells only. T as the argument causes GC to collect everything.