This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

sbcl howto find current memory usage

3 posts · 6981 views

I want to write an after-gc-hook which can detect that we are nearing the dynamic-space-allocation limit and throw an error.
However I have not been able to find and variables or functions which will report the current dynamic space usage.
(room) prints the desired info but I need to access from a hook.

So question is which functions or variables will report memory usage?

Re: sbcl howto find current memory usage

rich289 wrote:I want to write an after-gc-hook which can detect that we are nearing the dynamic-space-allocation limit and throw an error.
However I have not been able to find and variables or functions which will report the current dynamic space usage.
(room) prints the desired info but I need to access from a hook.

So question is which functions or variables will report memory usage?
I dug around in the SBCL source and managed to do this:
(push #'(lambda () (print (sb-kernel::dynamic-usage))) sb-kernel::*after-gc-hooks*)
(sb-kernel::gc)
Is that about right, or am I misreading you?
"If you want to improve, be content to be thought foolish and stupid." -Epictetus

Re: sbcl howto find current memory usage

sb-kernel::dynamic-usage is exactly what I was looking for.
Thank you very much.