Tracking & limiting the number of cons cells?



I am writing presently an AI for use with ulisp and I face the following issue - pertaining not just to ulisp:

How can I “keep track” how many cons cells my function is using while running, maximally? I.e. I define some starting point, then the system begins to track cell usage, and tries to periodically find out how many cells are in use. - I understand I could do something with (progn (room) (functioncall) … but is there something like some variable or debugging feature I might use, i.e. something more elegant?


Is there some way, too, to start some free Common Lisp implementation with a limit on the cons cells? - This is my main problem: I work super-creatively and freely on my multi-GB-machine, favouring a recursive (instead of iterative) style, and practically never running out of memory, only facing occasional trouble with speed. But with ulisp… memory ALWAYS seems to be an issue, and the difficulty to estimate makes it hard for me to port over my stuff. (Workaround: I figured out in Clisp I can say “clisp -m 100k” and indeed, generating lists of over 235 elements crashes and resets it, which is good, but I found no way to go for the cons cells themselves.)

I must say, the latest thing - Metro M4 Grand Central - got me super-interested, because 30K cons cells is, if I remember correctly, about that what you would get on an IBM 7094, i.e. a “real, big” machine of the early age.

Thank you!


Hi Aeneas,

In Common Lisp you can profile some code / function. It will not give you max cons usage, but it will give you info how many cells were consed. Memory limits as you found out already do not work on cons cells level (as far as I know).

In uLisp (room) looks like a way to go for cons cell usage.

Functional programming should not be an issue if you use Tail Call Recursion.