Linux – Does ‘ulimit -m’ Work on Modern Systems?

linuxmemoryresourcesulimit

This article claims that the -m flag to ulimit does nothing in modern Linux. I can find nothing else to corroborate this claim. Is it accurate?

You may try to limit the memory usage of a process by setting the maximum resident set size (ulimit -m). This has no effect on Linux. man setrlimit says it used to work only in ancient versions. You should limit the maximum amount of virtual memory (ulimit -v) instead.

If it's true that it worked in older versions of Linux, which version stopped supporting this?

Best Answer

It says right there in the article:

This has no effect on Linux. man setrlimit says it used to work only in ancient versions.

The setrlimit man page says:

 RLIMIT_RSS
        Specifies the limit (in pages) of the process's resident set
        (the number of virtual pages resident in RAM).  This limit has
        effect only in Linux 2.4.x, x < 30, and there affects only
        calls to madvise(2) specifying MADV_WILLNEED.

So it stopped working in 2.4.30. The changelog for 2.4.30 says something about this:

Marcelo Tosatti:
o Ake Sandgren: Fix RLIMIT_RSS madvise calculation bug
o Hugh Dickins: remove rlim_rss and this RLIMIT_RSS code from madvise. Presumably the code crept in by mistake

Related Question