Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 06-03-2008, 07:51 PM   #1
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 653

Rep: Reputation: 32
ulimit and /etc/security/limits.conf

I've taken a look at the threads on here and found various text's that tell me:

1) limits don't work the way people think they work
2) limits may not have the affect that one would expected, unless the code they are supposed to affect is written with limits in mind
3) IF they are used they should be used as part of a startup script, rather than refining the standard ones

Alas this does not dissuade people from demanding we tune them. Seeing as there is the potential for learning something interesting, i'm not disinclined to try

The central theme that continues to arise is that we want to limit the amount of RAM a process can consume. Thus i set the RSS to a hard limit of 8MB, and load my 64MB file into RAM using a quick perl script (three lines of code that reinforce once again that i need to learns some perl), and in another shell observe that the script is indeed consuming 13% of my 512MB RAM, which is my file + a slight overhead.

ulimit -a tells me my RSS is fixed at 8192 KBs, which is also what i set the Data Size to in /etc/security/limits.conf

*  hard  data 8192
*  hard  rss    8192

If anything this validates point 1 from above, it doesn't work the way at the very least i think it works, and 2) my code definitely did not consider what limits might be imposed. 3) is a mute point.

Any ideas how i can set a limit which limits memory consumption at xMB and actually have it honoured?


Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 06-04-2008, 05:43 AM   #2
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 653

Original Poster
Rep: Reputation: 32
incidentally. I've found that if i set the ulimit -v (virtual memory) which can not be set via /etc/security/limits.conf i can affect an "out of memory" message. But (as indicated above) this is not a straight forward 64MB limit, but rather it works at 256MB, but not at 128MB, even though my actual memory consumption is 64ish, but 140ish reserved for Virtual Memory.
Old 01-23-2011, 01:42 AM   #3
LQ Newbie
Registered: Feb 2008
Posts: 9

Rep: Reputation: 2
If you read the man page for limits.conf, under the section for rss, you should see the line "maximum resident set size (KB) (Ignored in Linux 2.4.30 and higher)". Virtual memory is also the worst item to set relating to rss usage. Many applications have a much larger virtual size then they have resident size. If you want to get some idea of the comparison between the two then the following command will show the virtual size and the rss for each application on your system, in megabytes, sorted by virtual size ascending and you can see how the virtual size is much larger then resident size:

while read rss vsz command; do rss="$(bc <<< "scale=2; ${rss}/1024")"; vsz="$(bc <<< "scale=2; ${vsz}/1024")"; echo "${rss} ${vsz} $command"; done < <(ps --no-headers -A -o rss,vsz,comm --sort vsz)
2 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/security/limits.conf reverse Linux - Security 4 10-20-2007 03:10 PM
interpretate limits.conf in crontab 223 Linux - General 6 10-05-2007 01:27 AM
limits are not working (limits.conf) PkerC Red Hat 3 06-22-2006 10:14 AM
meaning of /etc/security/limits.conf commands marceluda Linux - Security 1 05-11-2006 11:01 AM
/etc/security/limits.conf documentation? crazyeddie740 Linux - Security 1 06-19-2004 03:02 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:59 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration