KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to change internal stack sizes in 4D
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: February 7, 2007

Each process in 4D has a default stack size. In 4D 2003 you could use Customizer Plus to modify the default values. In 4D 2004 the stack sizes have been re-adjusted and can no longer be customized since Customizer Plus does not exist in 4D 2004.

However, your database might still require a bigger value. There is how you can modify that value.

The following method will create a resource file that will contain new values for stack sizes. The resource type for stack sizes is 4STK. The sizes in this code are the default values on Windows.


` Begin sample code---------------------------------------------------------------------
$resFile:=Create resource file("";"")
LONGINT TO BLOB(200000;$value;Native byte ordering )
SET RESOURCE("4STK";1;$value;$resFile)
SET RESOURCE NAME("4STK";1;"on event call";$resFile)

LONGINT TO BLOB(524288;$value;Native byte ordering )
SET RESOURCE("4STK";2;$value;$resFile)
SET RESOURCE NAME("4STK";2;"on serial port call";$resFile)

` Executed from User mode, new process in user mode
LONGINT TO BLOB(600000;$value;Native byte ordering )
SET RESOURCE("4STK";3;$value;$resFile)
SET RESOURCE NAME("4STK";3;"Exec on server, on client, from user mode, macro";$resFile)

` new process from the menu bar
LONGINT TO BLOB(1000000;$value;Native byte ordering )
SET RESOURCE("4STK";4;$value;$resFile)
SET RESOURCE NAME("4STK";4;"Exec process from menu";$resFile)

LONGINT TO BLOB(262144;$value;Native byte ordering )
SET RESOURCE("4STK";5;$value;$resFile)
SET RESOURCE NAME("4STK";5;"Server tasks";$resFile)

LONGINT TO BLOB(524288;$value;Native byte ordering )
SET RESOURCE("4STK";6;$value;$resFile)
SET RESOURCE NAME("4STK";6;"old backup";$resFile)

LONGINT TO BLOB(524288;$value;Native byte ordering )
SET RESOURCE("4STK";7;$value;$resFile)
SET RESOURCE NAME("4STK";7;"old restore";$resFile)

` web process
LONGINT TO BLOB(262144;$value;Native byte ordering )
SET RESOURCE("4STK";8;$value;$resFile)
SET RESOURCE NAME("4STK";8;"Web";$resFile)

LONGINT TO BLOB(1400000;$value;Native byte ordering )
SET RESOURCE("4STK";9;$value;$resFile)
SET RESOURCE NAME("4STK";9;"server event loop, cache, runtime explorer";$resFile)

LONGINT TO BLOB(1600000;$value;Native byte ordering )
SET RESOURCE("4STK";10;$value;$resFile)
SET RESOURCE NAME("4STK";10;"Apple event";$resFile)
CLOSE RESOURCE FILE($resFile)
` End sample code-----------------------------------------------------------------------


If you want to modify any of the stack sizes, replace its value in the appropriate LONGINT TO BLOB statement. You should only change values for IDs 3, 4 and 8. Other IDs are kept for compatibility or reserved by 4D and should not be changed.

Under MacOS X all stack values are set to 524288 by default, except for IDs 5 and 8, which are both set to 262144.

Once the file has been created, change its extension from .RSR to .4XR, drop that file inside your 4D Extensions folder and restart your 4D application. The file must be copied in the 4D Extensions folder for each 4D application that needs to use these new settings.