7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ulimitでメモリの使用量を制限する時

Last updated at Posted at 2015-07-09

ulimit -mを使う時は、-vも併用する。
(他にも考えることは多数ありますが・・・)

あと、よく見たら、子プロセスがーーとなって泣かない!
(Segmentation faultが発生しても。)


設定を各場所にも注意しましょう。

参考:
ファイルディスクリプタ数の上限変更とlimits.confの罠


※ulimitは、シェルの組み込みコマンドなので注意。


リファレンスを見つけにくいので。
http://ss64.com/bash/ulimit.html
http://ss64.com/bash/limits.conf.html
※limits.confに設定を書いた場合は、再起動後にも、制限が正しく反映されていることを確認しましょう。確認方法にも要注意。
(limits.conf以外の場所で設定した方が無難です。適用条件が限られるので・・)


SSH接続で、証明書を利用したログインや、PAM認証をオフにしている場合などにも注意。


確認方法の例:
cat /proc/(PID)/limits
参考:
ulimitが効かない不安を無くす設定

表示される内容:
Max resident set: (ulimit -m で設定した値)
Max address space: (ulimit -v で設定した値)
※limitsのUnits(表示単位)はbytesなので注意。
※Hard Limit: ユーザが変更できない上限、Soft Limit: (変更できる)設定値


メモリ制限のサンプル
http://unix.stackexchange.com/questions/34334/how-to-create-a-user-with-limited-ram-usage

7
8
0

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
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?