Using the /stack linker option correctly

I Love Xbase++ (ILX)
The portal for Xbase++ developers worldwide

Till Warweg

Member
Staff member
I am here to help you!
Feb 1, 2021
38
11
8
Customer Identifier
E074775
The default setting for the linker's stack option is one Megabyte. This means that the main thread and all other threads created by an Xbase++ application each get reserved one Megabyte of stack space. The stack space cannot be accessed directly by the application. Instead, this reserved area is used by the Xbase++ runtime for storing things like local variables, function return addresses and temporary buffers required for operation. Having enough stack available therefore is crucial for the stability of the application.

However, stack memory also is a precious resource. This memory must be contiguous and is allocated from a memory pool also being accessed by the operating system and also by the add-on tools used by the application. Therefore, in applications using many threads, increasing the stack size can lead to situations where no new threads can be created or other resource allocations fail due to memory shortage or fragmentation.

For these reasons, using /STACK for increasing the stack size is recommended only in special cases. Possible examples for this are:
  1. code using a high recursion depth
  2. code using a very large number of LOCAL variables, possibly in combination with 1.
  3. usage of unusually complex UI controls
In all other cases, the default stack size of one Megabyte should be sufficient and it is recommended to increase the stack size only if you experience abnormalities or crashes due to the issues outlined above.
 
Last edited: