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
11
votes
6 answers

CentOS How Much SWAP for 16GB of RAM?

How much SWAP would you give a CentOS install on a dual Quad Core XEON with 16GB of RAM that is going to be running a php website with a mysql backend - medium/heavy load?
Frank
11
votes
6 answers

SSD for swap on Ubuntu server

Currently I am reading SSD reviews and I wonder how much exactly I will benefit if I move the 24 GB swap from 7200rpm HDD to SSD. Does anyone implemented swap space on SSD? Is this generally good idea? On a side note: I read that ext4 has much…
grs
  • 2,235
  • 6
  • 28
  • 36
10
votes
2 answers

Why does Windows 2008 use swap before the memory is full?

I administer a Windows 2008 server (well, on Amazon EC2) running IIS and a .NET4 Web app. I got a memory alert the other day and went and looked, and sure enough the process memory had grown over time via some kind of slow leak. It didn't grow by…
Ernest Mueller
  • 1,189
  • 2
  • 12
  • 25
10
votes
4 answers

Constantly Increasing swap size in Linux and Swap space not being reclaimed?

I have a 8GB RAM linux box on which 4 tomcat servers are running. One of the them is set to 3000MB memory(jvm -Xms and -Xmx setting) and others are set to 1500MB. The swap partition is also set to 8Gigs. When I start these servers, the swap file…
Zenil
  • 281
  • 1
  • 2
  • 6
9
votes
3 answers

How can I create a swap partition on Amazon EC2 with ephemeral storage?

This is the output of df -k: Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda1 10317860 7059008 2734732 73% / none 847584 0 847584 0% /dev/shm /dev/xvdb 153899044…
Pandora
  • 135
  • 1
  • 3
  • 7
9
votes
2 answers

How is htop "Swp" calculated?

When I run htop (on OS X 10.6.8), I see something like this : 1 [||||||| 20.0%] Tasks: 70 total, 0 running 2 [||| 7.2%] Load average: 1.11 0.79 0.64 3 [|||||||||||||||||||||||||||81.3%] …
Weier
  • 193
  • 1
  • 1
  • 4
9
votes
3 answers

Using tmpfs + a very large swap partition for /tmp instead of a regular filesystem?

I have Linux server and I have a spare 500GB disk partition. I wanted to format it and use it for /tmp. The server occasionally runs some large data processing tasks so it can happen that /tmp will hold GBs of temporary data. Then I got an idea that…
Petr
  • 501
  • 1
  • 5
  • 13
8
votes
1 answer

Create swap file on a running Linux machine

Our company web sites have just been moved from a shared host to a VDS, as the hosting company plans on retiring the less than completely reliable shared hosting server(s). The VDS only has 256MB of RAM and hosts a few sites, all but one of which…
John Gardeniers
  • 27,262
  • 12
  • 53
  • 108
8
votes
8 answers

Do I even need a swap partition with Linux?

I have a core 2 laptop with 4gb of ram. I use the machine for browsing, network stuff and simple programming. (I use this machine to host a small ftp and web server semi-occasionally.) Would there be any benefit to having a swap partition? My…
Bill Gray
  • 1,295
  • 1
  • 11
  • 18
8
votes
4 answers

When is swap moved back to physical memory?

When is swap moved back to physical memory in Linux? Is it only on demand, ie. when it's needed? Or is swap slowly transfered to physical memory when the computer is not on high load?
Ztyx
  • 1,365
  • 3
  • 13
  • 27
8
votes
3 answers

Running out of swap space on web servers, what to do?

I have 2 LAMP web servers that are routinely running out of swap space (see attached top screenshot). Apache's settings are as follows: StartServers 64 MinSpareServers 64 MaxSpareServers 128 ServerLimit …
mmattax
  • 1,284
  • 7
  • 19
  • 30
7
votes
3 answers

What is the danger in having a fully used SWAP in an Ubuntu server?

One of my Ubuntu servers' swap partition is full. What are the dangers and/or performance ramifications of this situation?
Itai Ganot
  • 10,424
  • 27
  • 88
  • 143
7
votes
2 answers

Linux OOM disk I/O. Also: swap, what is it good for?

I'm having problems with the OOM killer on one of my Linux (2.6.37) installs. The computer has 4GB of memory which I sometimes utilize fully. In those cases, I expect the OOM handler to come in and do its job by killing a process or two. Instead…
extramuros
  • 73
  • 1
  • 4
7
votes
2 answers

Where should my swap partition/s live when using software RAID1? Performance? LVM?

When I search around for example RAID1 installations, it seems that admins tend to place their swap partition under RAID1. To me, it is more intuitive to have two disks, each with a large partition for use by RAID1 and the system partition and with…
andyortlieb
  • 1,052
  • 1
  • 12
  • 25
7
votes
6 answers

Why should swap size be same or larger than RAM?

Many say that, if you have a 2GB RAM, you should configure a 2GB or more swap. FWIK the hibernation may need the same size swap to persist memory when power off, but generally, if you got a big RAM, you even don't need swap at all, isn't it? For…
Xiè Jìléi
  • 782
  • 7
  • 13
  • 27
1 2
3
22 23