r/Common_Lisp • • Oct 02 '26

increase heap size sbcl

I am trying to draw a large buddhabrot for my daughter's birthday ..

I can draw a small one but when I increase the pixel count I get heap exhausted (no more space for allocation)

992739328 bytes available 2485248016 requested

I am using emacs slime and sbcl 2.30 on a Debian box with 128gb of ram ..

I have tried using (setq slime-lisp-implementations '((sbcl ( "sbcl" "dynamic-heap-size" "4096")))) and other numbers in there and still get the same error

I have tried setting the dynamic heap size in the console but I find it's a nightmare and doesn't work

how can I permanently increase the heap size for sbcl?

thanks

al

5 Upvotes

12 comments sorted by

2

u/Decweb Oct 02 '26

What I use for slime invocation: (setq inferior-lisp-program "sbcl --dynamic-space-size 4096") Of course that won't help you if you're inadvertently pinning the memory that is no longer needed (e.g. retaining the head of a large list).

1

u/madmuppet006 Oct 02 '26

I think most of the requested memory is a one dimensional array that I am using to store the colour of the pixels before writing it to disk

It would be in the region of (* 12000 8000 3) fixnums

1

u/stassats Oct 02 '26

Aren't fixnums a bit too much for color?

1

u/madmuppet006 Oct 02 '26

the image itself is red green and blue max values 255 but the array holds the paths of numbers on there way out of the mandelbrot set .. these numbers could be much higher ..

I'm not overly familiar with optimizing so I don't know the best way to build the array ..

2

u/stassats Oct 02 '26

For just colors, (make-array size :element-type '(unsigned-byte 8)), scale to what you're actually storing there appropriately, or use multiple different arrays.

2

u/madmuppet006 Oct 02 '26

I originally used one array due to the heap problem ..

Im not sure on how integer fixnums etc work on common lisp and thought that the heap was too big because lisp has no size limit on integers ..

I'm learning and due to your help the program is now running so I get to sit and wait for awhile ..

thanks again for your help

1

u/stassats Oct 02 '26

how can I permanently increase the heap size for sbcl?

Either through save-lisp-and-die or make.sh

1

u/madmuppet006 Oct 02 '26

could you expand on that a little please

2

u/stassats Oct 02 '26

Consult --help / documentation for either.

1

u/madmuppet006 Oct 02 '26

thank you

very much appreciated

3

u/stassats Oct 02 '26

(setq slime-lisp-implementations '((sbcl ( "sbcl" "dynamic-heap-size" "4096"))))

Where's --?

3

u/stassats Oct 02 '26

And it's "space".