Is there a way to increase the default stack size in excess of 16777216 bytes?

This question says it all. Attempting to increase the stack size in the linker options raises an error:

The maximum stack size must be an integer from 65536 to 16777216.

Is this 16 MB limit a fundamental limitation of the Delphi compiler, or is it an arbitrary limit imposed by the IDE? Is there any other way to increase this value?

Note (awaiting comments ...):

  • The need for a larger stack is due to the huge static types of arrays used as local variables.
  • I understand that having to do this is a symptom of a terrible design.
  • This is a great legacy application whose design and maintenance I am not responsible for.
  • Refactoring for dynamic arrays works, but performance is reduced by 50%.
  • Other refactorings are possible - perhaps weeks of work. This is likely to be a side project.
  • At the same time, functionality is needed now, and a large stack will be an easy fix.
  • Yes, I really know that this is bad, bad.
+4
source share
2 answers

You can increase it to 2147483647 using the directive {$MAXSTACKSIZE}(or {$M minstacksize maxstacksize}compiler). This is a different use for {$M}than {$M+/-}used to indicate the generation of RTTI for classes.

From the Xc6 docwiki (it also applies to previous versions):

$M . minstacksize 1024 2147483647, , maxstacksize minstacksize 2147483647, .

, Windows .

+4

IDE Delphi. , $MINSTACKSIZE $MAXSTACKSIZE. , IDE - IDE, .

, . , , . , , . , CreateThread.

, , , .

+2

All Articles