Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    "swapping of memory" priority

    I emulate workload with this simple program in C language, let's call it "use-memory":
    #include <malloc.h>
    #define SIZE 160000000
    int main (void) {
    	char *p;
    	char *p0;
    	int i;
    	int a;
    	p0 = malloc (SIZE);
    	a = 0;
    	if (p) {
    		while (1) for (i = SIZE, p = p0; (i -= 1000) >= 0;) {
    			p[i] = (char) a;
    	else {
    		return (-1);
    I run N processes. If (N * SIZE > "amount of physical memory in bytes"), then all programs became very slow. Including "bash" and "kill", so even killing of "use-memory" becomes hard. (Do not try N>8.) I think that this is because of intense swapping of memory of "use-memory". The problem is that other programs get swapped too.

    I want "memory usage priority", like I/O priority ("ionice") and CPU priority ("chrt"). It should work like this: a program with lower priority may not force to swap memory of a program with higher priority.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    This is, AFAIK, not a capability in the current kernel(s) of Linux, prioritization of memory usage (swap, vs. in-core). Sounds like you need to think about some kernel modifications, at least on an experimental basis. Hitting the swapper is a known issue with system performance. In fact, real-time systems usually don't support swapping because it negatively affect the determinist performance behavior required by real-time systems.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts