Pages

How to limit memory usage per user in Linux


It is possible to limit the amount of memory that each process can allocate with the RLIMIT facility in Red Hat Enterprise Linux. RLIMIT_AS limits the size of the virtual address space and it is a suitable solution in many cases which require limiting per-process memory consumption even though there are many limits related to memory.


# vi /etc/security/limits.conf
.... 
daniel hard as 1048576  
.... 

# ulimit -v
1048576

In the example above, processes running as 'daniel' user can only use 1GB virtual address space. So, each application used by daniel cannot allocate more than 1 GB memory space.

Note : this limitation does not affect an amount of physical memory directly, and the values are in KiB (1024-byte).

No comments:

Post a Comment