------------------ What is SWAP? -------------------
- A:
SWAP: is a backup for DRAM.
SWAPPING: Is the action of moving DRAM file's to your Hard drive.
---- How SWAP works ----
- SWAP is a dedicated partition/file (space), created to assist the physical memory (DRAM). When the DRAM is full, or reaches the set parameters, the kernel will move (called: "Swapping in" or "Paging in") idle App (Data), to the SWAP space. This action frees up the DRAM. Thus running the Priority Process/Data needed. (Making the machine perform better).
------------ What is Swappiness? ---------
- A:
Swappiness is the set parameters/Threshold for when swapping should happen.
----- Configuring the Swappiness: -----
-
First lets understand the parameters of swappiness values:
Swappiness parameter values are between 0-100. -
The higher you set the swappiness value, the earlier/more swapping will happen.
Eg; vm.swappiness set @ 90, will start swapping at 10% of DRAM capacity. -
The lower you set the Swappiness value, the Later/less swapping will happen.
Eg; vm.swappiness=10 will start running swapping at 90% of DRAM usage.
_________What happens when swapping occurs ______
- For the example i will be playing a game online & have my email open in the background. On a 5Gb DRAM machine.
The game uses 4Gb of DRAM, my system had shifted my 1Gb of email data to the swap file due to set swappiness value.
While playing i received an email,
The system then has to put the email data back in to the DRAM ( Called: swapping out or paging out),
so you can use the email. when you resume your game, the system will swap back the email data to the swap file if needed again.
------------ MYTH -----------
-
Myth:
SWAP is not just for Older/low spec machines.
It also plays a roll in hibernation Mode. -
Swappiness set to (Zero). Does not Disable swap. It will only swap when needed.
Swapping will/can still happen at anytime due to peeks/spike of DRAM demand, this can happen at any % of RAM usage.
----- Problems that may occur relating to SWAP: -----
Eg:
- Your machine is Lagging, a shuffling mouse cursor, little shutters, etc.
Not often, but lets say:
-
Your running your DRAM at 40% capacity, (by default this is the SWAP switching parameter on Zorin/Ubuntu-Ditro's) More so on low spec machines HDD/slow.
If 40% DRAM usage is normally where your system runs, It would be a valid reason to increase the swapping, by decreasing the Swappiness value. -
Solution: Change the Swappiness parameters. (Set SWAP at 50% of full DRAM) So Swappiness value would be;
(vm.swappiness=50). -
Note:
It's ok to have large SWAP Space to help, but you need to understand how it works (When & where to use a large SWAP space).
-------- Hibernation issue's: -------
- If your machine has 8Gb of DRAM & 8Gb of SWAP space. so now the machine can have up to 16GB of memory (8Gb DRAM + 8Gb SWAP).
Let say you have 10Gb in use.( 8Gb in DRAM +2Gb in swap file)
This will not hibernate due to, 10Gb's will not fit into the 8Gb SWAP space.
So if your machine will not hibernate, or just goes to Sleep instead, the above reason may apply.
-- What happens to DRAM/SWAP on Sleep/Shutdown --
Sleep/Suspend Mode & Standby:
- Saves your "Last state" in RAM , (due to power still being available to the system)
Hibernation Mode or Shutdown:
- Saves the "Last state" to your Hard drive ,( allows the machine to totally power down)