This question already has an answer here:

Occasionally some processes on my GNU/Linux desktop (such as gv and gnash) use up the physical memory and cause thrashing. Since these processes aren't important, I want them to be automatically killed if they use too much memory.

I think the /etc/security/limits.conf file and the -v option could be used for this. The question is whether it limits the amount of available memory per process of a particular user, or the sum for all the processes of a user. Also I would like to ask how to make change to that file in effect without rebooting.

marked as duplicate by roaima, Sparhawk, garethTheRed, Eric Renouf, vonbrand Oct 25 '15 at 13:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


There's also the ulimit mechanism. There's a system call (in Linux, it's a C library function) ulimit(3) and a Bash builtin ulimit. Type ulimit -a to see all the things you can limit to. To see the current virtual memory limit say ulimit -v. You can set it by saying ulimit -v INTEGER-KILOBYTES.

Running ulimit changes things for your current shell, and you can only select a value smaller than the current one. To run a command with limited virtual memory, you can just use a Bash sub-shell:

( ulimit -v 131072; some-app )

limits.conf will apply to users example : oracle soft memlock 3145728 oracle hard memlock 3145728

otherwise if you re looking for a per process limit .. take a look at sysctl -a for a permanent effect .. you could add your params to sysctl.conf

good luck

Not the answer you're looking for? Browse other questions tagged or ask your own question.