IBM Support

How to set the KSH_STAK_SIZE environment variable only to the specified script.

How To


Summary

The ksh command will fail to allocate memory required for script variable if there is memory requirement in MB's and it fails with this error "“0403-029 There is not enough memory available now.” Any command or script that creates ksh variables with size in MB's might fail.

AIX offers KSH_STAK_SIZE environment variable to prevent this error and we have to export the environment variable with space to satisfy the needs of the script variable.

export KSH_STAK_SIZE=2MB.

If we export like this all script, that we are executing gets stack size 2MB, even if that is not required for them. We can solve this in two ways:












Objective

1.  We need to develop wrapper script to set this environment and execute the script that require this stack size like this. 
 
# cat  1.sh 
#!/usr/bin/ksh
#export KSH_STAK_SIZE=2MB
./ksh_enomem.sh
rc=$?
exit $rc 
 
(0) root @ fvtrain49-lp3: /
# ./1.sh 
./ksh_enomem.sh[2]: 0403-029 There is not enough memory available now.
 
(1) root @ fvtrain49-lp3: /
# cat ksh_enomem.sh
#!/usr/bin/ksh
test=`cat ./test.out`
exit 0
 
(0) root @ fvtrain49-lp3: /
# cat  1.sh
#!/usr/bin/ksh
export KSH_STAK_SIZE=2MB
./ksh_enomem.sh
rc=$?
exit $rc 
 
(0) root @ fvtrain49-lp3: /
# ./1.sh
 
(0) root @ fvtrain49-lp3: /
# 
2. execute the script by setting KSH_STAK_SIZE in command line: 

# set KSH_STAK_SIZE=2MB ksh_enomem.sh

(0)


Environment

AIX

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG10","label":"AIX"},"ARM Category":[{"code":"a8m0z0000001fMuAAI","label":"AIX General Support"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Document Information

Modified date:
06 September 2022

UID

ibm16606295