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
2
votes
2 answers

Using swap even though 20GB free memory, swappiness=0

We have a CentOS 7 server that goes into swap a little bit about once a week, despite having > 20GB of available memory, and swappiness is set to 0. We want to be able to use swap as a sort of sentinel that we are running out of memory without…
Jay Paroline
  • 159
  • 1
  • 9
2
votes
2 answers

Active process swapping despite free memory

For some reason our system starts swapping (actively used memory) at around 60GB used memory. (see edit below, it seems I/O and disk cache usage, even of previously run processes has an effect) Turning it off (swapoff-a) for test lead to bad_alloc's…
b.buchhold
  • 121
  • 2
2
votes
1 answer

Linux Mint: Python process gets "MemoryError" before swap is even close to fully used

I'm attempting to run a Python script that requires a lot of Virtual Memory. I'm on Linux Mint 17.3 64 bit and Python 2.7. As the Python process grows, I can see (using free -m) the amount of RAM use increase, but the amount of swap space used…
user1084684
  • 155
  • 1
  • 7
2
votes
0 answers

Linux swap partition not mounted by systemd on boot after dist-upgrade

Recently, I performed a dist-upgrade from Debian Wheezy to Jessie. The upgrade was performed without any error but after the upgrade the swap partition was no longer mounted/activated. The mentioned system is a KVM (qemu-kvm, centos7). During the…
YuTendo
  • 21
  • 1
  • 4
2
votes
2 answers

Why takes CLEARING swap soo long?

Why is moving from RAM to swap fast and from swap to RAM very slow? When I run program that needs more memory that is available, I see that the RAM is prety quickly "cleaned" by moving unsused (=the least accessed) pages to swap. But then when I…
mvorisek
  • 485
  • 6
  • 19
2
votes
1 answer

Linux hibernate: how to specify a swap partition to store data if I have two?

We can specify the swap partition to load data from when recovering from a systemd hibernation using kernel argument resume=/dev/xxx. However, I didn't find any command-line or kernel argument to choose which partition to swap into. $ sudo systemctl…
Lv Zheng
  • 131
  • 2
2
votes
2 answers

Linux Swap used is higher than total

I found a bizare think on my server. The swap used is significantly higher than the total swap. free -m total used free shared buffers cached Mem: 1869 1788 80 71 35 …
2
votes
1 answer

How do you know when server memory needs to be increased?

I have a VPS running a few websites for clients. Running free -h shows the following: ~$ free -h total used free shared buffers cached Mem: 994M 855M 138M 39M 72M 420M -/+…
2
votes
1 answer

Forcing a user to use swap space after certain memory usage (using limits.conf?)

I have a backend app that is being used internally by developers hosted on our server, however, the app unfortunately requires the use of Passenger and Ruby, both of which are very memory-hungry. I have an SSD swapfile that should allow reasonable…
Ecksters
  • 123
  • 4
2
votes
1 answer

How do I increase the swap size on a xen guest machine using xm?

I'm attempting to increase the amount of swap on a xen guest machine. At first I thought it'd be similar to increasing the hard drive space, which I do like this: cd /srv/xen/domains/$host/ xm shutdown $host cp disk.img disk.img.backup dd…
lucas
  • 200
  • 3
  • 10
2
votes
1 answer

Swap 99% but regular memory fine

I have a 1GB VPS server. I setup 1GB of swap ram too a few weeks ago and quite often it's hitting 99% whilst the regular memory is usually 40% - 60%. Most of my sites on the server run fine and fast. But the wordpress website I am developing is very…
wharfdale
  • 151
  • 8
2
votes
1 answer

puppet logical conditions- "onlyif" and "unless" not working

I have written the following code and this works fine if swap is not in place, but once swap is created and if the script is executed again, it leads to error. I tried adding conditions using onlyif and unless which are commented in the following…
user228708
  • 63
  • 1
  • 1
  • 7
2
votes
0 answers

Linux (Debian 7 x64) swapping activity despite lots of free memory

Yes, I have reduced vm.swappiness a lot: % sysctl -a | grep swap vm.swappiness = 1 Memory is mostly free: % cat /proc/meminfo | head MemTotal: 8070592 kB MemFree: 2619580 kB ps_mem.py…
LetMeSOThat4U
  • 1,159
  • 2
  • 14
  • 29
2
votes
3 answers

Is there any reason to NOT have a swap file on CentOS (DigitalOcean)

I'm running a site on DigitalOcean with CentOS 6.5. As has been noted elsewhere, DigitalOcean servers are by default configured without any sort of swap, and I'm wondering if I should add one. I know just enough about this stuff to think that the…
Jim Miller
  • 713
  • 2
  • 11
  • 23
2
votes
1 answer

My Ubuntu VPS is not using available swap, even if OOM. What to do?

I recently added 1 GB of swap to my Ubuntu virtual private server to prevent MySQL crashes on RAM overloading. I followed this tutorial. I use htop to monitor resources. When I use loadimpact to test my server it crashes when no more RAM is…