tags:

views:

701

answers:

2

According to the manpage, "-l" in ulimit means "The maximum size that may be locked into memory". What does this sentence mean, exactly? How may it affect running programs?

A: 

Memory that is locked may not be paged out - this reduces the amount of memory that is available for other processes. This setting limits the amount of memory that can be locked.

1800 INFORMATION
is it means if I set it to 100M and then start the program (let say a java program), it will keep it in memory and won't page out?
Eric Yung
Not exactly. The program would then have to lock the memory, and this is a limit on the user, not per program, so other programs could lock memory and use some of the allocation
1800 INFORMATION
The ulimit only limits how much you can lock. You need to call mlock or mlockall for it to be actually locked.
+2  A: 

This limits how much memory you can make unswappable with mlock

The setrlimit manpage says:

The maximum number of bytes of memory that may be locked into RAM. In effect this limit is rounded down to the nearest multiple of the system page size. This limit affects mlock(2) and mlockall(2) and the mmap(2) MAP_LOCKED operation. Since Linux 2.6.9 it also affects the shmctl(2) SHM_LOCK operation, where it sets a maximum on the total bytes in shared memory segments (see shmget(2)) that may be locked by the real user ID of the calling process. The shmctl(2) SHM_LOCK locks are accounted for separately from the per-process memory locks established by mlock(2), mlockall(2), and mmap(2) MAP_LOCKED; a process can lock bytes up to this limit in each of these two categories. In Linux kernels before 2.6.9, this limit controlled the amount of memory that could be locked by a privileged process. Since Linux 2.6.9, no limits are placed on the amount of memory that a privileged process may lock, and this limit instead governs the amount of memory that an unprivileged process may lock.