1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[AIX]KSH_STAK_SIZE環境変数

Posted at

[AIX]KSH_STAK_SIZE環境変数

kshでは変数へ文字列を格納しようとした際に、格納先の領域が不足すると既に獲得している領域より32KB大きな領域を新たに確保します。
そこに以前の文字列データをコピーし、追加の文字列を格納する動作を繰り返します。
例えば1MBのデータを格納する場合、最初に32KB、次に64KB、その次は96KBとメモリーを確保していきます。
その際、古い領域は保管されたままになるため、32KB、64KB、96KB…960KB、992KB、1024KBの合計メモリ(約16MB)が確保されます。
同様に、2MBのデータを格納するには約6MB、5MBのデータを格納するには約400MBの一時領域が使用されます。
最終的に全ての文字列の1つの領域へ格納し終わった段階で古い領域は解放されますが、一時的に非常に大きなメモリが必要になります。

結果として、数MB程度のデータを変数に格納できないことがありますが、この実装はkshの本家による実装のため、AIX独自に変更できるものではありませんでした。
KSH_STAK_SIZE環境変数は上記32KBを任意のサイズに変更します。

スクリプトの例:

test=`cat ./test.out`

エラーメッセージの例:

0403-029 There is not enough memory available now.

環境変数の使用例:

export KSH_STAK_SIZE=2MB

参考: How to set the KSH_STAK_SIZE environment variable only to the specified script.
https://www.ibm.com/support/pages/how-set-kshstaksize-environment-variable-only-specified-script

IJ27253: DOC APAR FOR KSH_STAK_SIZE
https://www.ibm.com/support/pages/apar/IJ27253

IV77567: KSH RUNS OUT OF MEMORY WHILE ASSIGING FEW MB DATA TO A VARIABLE APPLIES TO AIX 7100-04
https://www.ibm.com/support/pages/apar/IV77567

Korn シェル (POSIX シェル) で使用される変数
https://www.ibm.com/docs/ja/aix/7.3.0?topic=shell-variables-used-by-korn-posix

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?