Thursday, April 30, 2009

limits.conf: virtual memory limit

I was setting some limits on CentOS 5.2 with 24GB of RAM. I wanted to set a limit to virtual memory for a process of group of users to be no more than 4GB. Normally, you a user can do this for its own bash session usingulimit -v 4000000I wanted to do the same thing but to as a root (i.e. admin of a server) to a group of users. Such limits can normally be set in /etc/security/limits.conf. There are many limits# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open files
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to
# - rtprio - max realtime priority
However, I could not find anything for virtual memory, nor I could find any info about this in the Internet. Therefore, I used the try-and-see approach. Finally, I found that item "as" (i.e. address space limit (kb)) does this! Therefore I made a limit to a group @somegroup hard as 4000000To check it, I logged in to a server using ssh as a user from the "somegroup" and executed[test@w ~]$ ulimit -a | grep virtual
virtual memory (kbytes, -v) 4000000
This is of course a limit per process of a user from this group, and not limit for a user of a group!


  1. Anonymous9:01 AM

    Basically you saved the day. ;)

  2. Anonymous3:50 AM


  3. Anonymous2:38 PM

    Dear sir, you are my savior.

  4. Anonymous4:46 PM

    Thanks! Was looking for this as well, too bad this isn't explained in limits.conf(5)

  5. I had this issue recently with my server and not sure why it wasn't set to unlimited.
    Now everything is ok.

  6. Anonymous8:03 AM


  7. Hi This saved a lot of search effort
    a quick question
    how to make this change reflect to the running processes

  8. Anonymous2:01 PM

    Благодарю! Вы - мой спаситель!

  9. Anonymous10:34 AM

    Thank you 2009 from 2019!