2

Are there any common lisp implementation that allow modifying the stack size at run-time? What about the size of the heap?

I am using sbcl and apparently these are defined when the executable is started, and cannot be altered afterwards.

1
  • What are you aiming to accomplish with this? The fact that you're fiddling with the stack dynamically is a bit odd Commented Aug 11, 2013 at 4:40

1 Answer 1

6

For example ECL and LispWorks can extend the stack at runtime. One can see that both are also offering restarts when there is a stack overflow, to increase the stack size, if necessary:

ECL:

>  (defun s (n)
     (if (zerop n) 0 (+ 1 (s (1- n)))))

S

> (s 100000)

Condition of type: STACK-OVERFLOW
C-STACK overflow at size 4259840. Stack can probably be resized.

Available restarts:

1. (CONTINUE) Extend stack size
2. (RESTART-TOPLEVEL) Go back to Top-Level REPL.

Broken at S. In: #<process TOP-LEVEL>.
>> 

See the ECL memory management documentation at: http://ecls.sourceforge.net/new-manual/re86.html

LispWorks:

CL-USER 31 > (s 1000)

Stack overflow (stack size 15997).
  1 (continue) Extend stack by 50%.
  2 Extend stack by 300%.
  3 (abort) Return to level 0.
  4 Return to top loop level 0.

Type :b for backtrace or :c <option number> to proceed.
Type :bug-form "<subject>" for a bug report template or :? for other options.

A variable in LispWorks allows customization: SYSTEM:*STACK-OVERFLOW-BEHAVIOUR*. See http://www.lispworks.com/documentation/lw61/LW/html/lw-1440.htm#marker-887330 .

The heap grows automatically in most implementations by requesting more memory from the operating system. The next question then would be: can the heap shrink?

Sign up to request clarification or add additional context in comments.

2 Comments

What about ccl? Out of curiosity, would it be hard to implement a dynamically resizable stack in sbcl?
@stackman: In CCL you can set the stack size of thread, if you start a new one. How hard is in to implement in SBCL? I have no idea. You would have to ask the implementors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.