-1

When I run a top and get it to show swap usage, I get the following output. However, I have disabled swap with swapoff -a prior to starting firefox. What is shown in the SWAP field here then? When I do cat /proc/meminfo, I get a nonzero value for a field named SwapCached. What is this? My guess it this is the aggregate of all the SWAP values shown in top. How are these related to total memory used by a process?

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP 
    COMMAND                                                                                                                                      
         1604 dumrat    20   0  287m  62m  26m R    1  3.1   0:05.03 225m firefox-bin                                                                                                                                  
         1415 dumrat     9 -11 94264 4668 3552 S    0  0.2   0:00.10  87m pulseaudio 
nakiya
  • 14,063
  • 21
  • 79
  • 118

1 Answers1

1

My best guess id this.

When you say swapoff, it prevents tasks from further 'swapping' (techically, it's paging, not swapping), but does not remove already swapped pages from swap devices. Often various shared libraries go to swap right at the moment of loading: they are here to stay for long time, no point wasting time swapping them when the load is high. These libraries are in RAM as long as they are needed by active processes, but also in swap space.

Maybe Firefox uses some of these librsries that are already mapped to swap space — Xlib, GTK, etc, and this swap space is counter to its 'SWAP' column. Linux tends to count all shared pages to each process that shares them, RAM or not.

Again, this is my guess; take with a grain of salt.

9000
  • 39,899
  • 9
  • 66
  • 104