I would like to limit the amount of physical memory a process can use without limiting the amount of virtual memory it can use. I am doing this in an effort to measure the behavior of various algorithms under memory pressure, and I need to test their performance with many different amounts of physical memory available - so I either need to buy a crapton of memory in lots of obscure sizes, or I need an operating system which supports limiting resident memory of a process in some way.
Unfortunately, Linux doesn't respect/enforce setrlimit(RLIMIT_RSS, ...)
, and neither does OSX.[1] Could you recommend me an operating system that CAN do this? Any of the non-OSX BSDs? Is there a mechanism to do this in Solaris? Can some variant of Windows do this?
[1] Linux ignores the request entirely, and OSX only uses it to decide what to swap out first when physical memory is exhausted. Neither of which helps me analyze the behavior of an algorithm when only X Megs of memory are available for use. It turns out Linux doesn't have any mechanism for doing this in the kernel, so it's pretty much out entirely unless someone can point me to a kernel fork which enables this. Solaris doesn't even have that option to setrlimit()
, but it may have another way that I don't know about.