Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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.

share|improve this question

marked as duplicate by roaima, Sparhawk, garethTheRed, Eric Renouf, vonbrand Oct 25 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.

Related SO question. – jw013 Jan 9 '12 at 15:29

2 Answers 2

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 )
share|improve this answer

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

share|improve this answer

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