Questions tagged [swap]

Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory(RAM) and the swap space is the amount of virtual memory available. Linux has two forms of swap space: the swap partition and the swap file.

From linux.com All about swap space:

Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available.

Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache. However, swapping does have a downside. Compared to memory, disks are very slow.

Linux has two forms of swap space: the swap partition and the swap file. The swap partition is an independent section of the hard disk used solely for swapping; no other files can reside there. The swap file is a special file in the filesystem that resides amongst your system and data files.

Swap space size should be either similar to system RAM or double it's size.

340 questions
1
vote
1 answer

Remove swap completely or set swappiness to 0?

In managing a server with 512GB of RAM I encountered a process that keeps consuming swap until it hits 100% of the swap space then stops consuming more (6GB of swap) but keeps working fine (albeit, when a request enters the process, it takes a long…
Gizmo
  • 279
  • 2
  • 11
1
vote
2 answers

Java crash due to native memory allocation map failure, despite n

A Java 11 application is crashing in a manner that from my understanding is impossible with the settings I have. The application in question runs on Amazon Linux 2, utilizing Java 11. The server is a cloud EC2 with 4 GB of ram. The server has no…
Michael Long
  • 11
  • 1
  • 2
1
vote
2 answers

FreeBSD swap usage with mysql

For the past few months, on a few different servers with similar FreeBSD versions and specs, I've been experiencing high swap usage with MySQL while seemingly having plenty of free RAM. FreeBSD 11.2-RELEASE-p8 (Also was happening in p2) …
Duncan Fairley
  • 63
  • 1
  • 1
  • 10
1
vote
1 answer

Increasing swap space and removing previous swap space on ubuntu?

I have a virtual machine (hosted online) with 2Gb swap space. free -m total used free shared buffers cached Mem: 1995 438 1557 37 22 190 -/+ buffers/cache: 225 …
Sasha Grievus
  • 223
  • 2
  • 11
1
vote
3 answers

Missing mdam RAID1 array during scan

I have built a new server (Ubuntu 18.04.1) with 4 HDD. My plan is to use RAID1 overall and came up with this layout after investigation: sda, sdb four primary partitions (all as fd) with sda1/sdb1 as /boot, sda2/sdb2 as /, sda3/sdb3 as /var and…
IgorLopez
  • 39
  • 1
  • 4
1
vote
1 answer

Proxmox doesn't recongnize increased swap space

So I tried to increase the swap LV from 8GB to 16GB, but Proxmox web panel doesn't seem to see the change. The LVM increased the space, but Proxmox haven't changed it's panel. Originally lvdisplay gave this result: --- Logical volume --- LV Path …
JoakimE
  • 138
  • 1
  • 7
1
vote
2 answers

High swap usage on CentOS server with plenty of spare RAM

We have a fleet of web hosting servers all running the exact same software & hardware with similar load. One of our server gets very high load that leads to it locking up for brief periods of time. The main difference for this server seems to be…
Kyle Vail
  • 13
  • 1
  • 5
1
vote
0 answers

OOM killer kills process though page cache is never evicted

Our servers in production sometimes under load runs into the following issue (Linux 4.10): Application handling the load (webserver) is running at high load. A new job starts (e.g. cron). This requires a clone() system call, which fails to allocate…
Confused
  • 11
  • 1
1
vote
1 answer

How to prevent kernel I/O thrashing in absence of swap memory on Linux?

I had problem with a process spawning very many threads due to a bug, eating up memory, causing heavy swapping to the swap partition. Thus, I switched off swap – which is recommended in server clusters anyway – to let the buggy program fail early. …
Torsten Bronger
  • 226
  • 1
  • 2
  • 10
1
vote
1 answer

dd using all memory and swap

I have a dedicated Centos 6.9 linux server with a company that crashed due to hardware failure and has been restored with the old HDD's on a usb caddy. I am trying to move lvm partitions over to the new internal hard disks. I have created a new…
williame
  • 13
  • 3
1
vote
1 answer

I loose the swap every time I restart my Ubuntu server

Here is how I set the swap: sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1MB count="1000" sudo /sbin/mkswap /var/swap.1 sudo /sbin/swapon /var/swap.1 Every time I reboot/restart the swap is gone. The command free gives me zeros for swap. But the…
jnbdz
  • 897
  • 5
  • 22
  • 43
1
vote
1 answer

RAID-10 for swap: Optimal chunk size

I would claim that if I had a RAID-10 array which is used as swap device only, a chunk size of 4K would be perfect as it matches the page size. Am I right?
1
vote
1 answer

swapon & hibernate on power key

I have a laptop & I run Arch Linux. My laptop has a spinning hard drive rather than an SSD, so I hate swap. However, I need one to hibernate, and I want my laptop to hibernate every time power key is pressed or battery runs low. My idea now is to…
1
vote
2 answers

docker container + java application -> swap used -> why?

There is docker container with java application inside. docker inspect dbc237493367 | grep -P '((Memory)|(Pid))' "Pid": 16283, "PidMode": "", "Memory": 10737418240, "KernelMemory": 0, "MemoryReservation": 0, "MemorySwap": -1, "MemorySwappiness":…
Oleg Golovanov
  • 193
  • 3
  • 6
1
vote
1 answer

Database files and the system swap space on the same disk?

Why is it problematic to configure the database files and the system swap space on the same disk? What can happen?