How much should be the swap size? Should the swap be double of the RAM size or should it be half of the RAM size? Do I need swap at all if my system has got several GBs of RAM?
Perhaps these are the most common asked questions about choosing swap size while installing Linux.
It’s nothing new. There has always been a lot of confusion around swap size.
For a long time, the recommended swap size was double of the RAM size but that golden rule is not applicable to modern computers anymore. We have systems with RAM sizes up to 128 GB, many old computers don’t even have this much of hard disk.
But what swap size would you allotto a system with 32 GB of RAM? 64GB? That would be a ridiculous waste of hard disk, won’t it?
Before we see how much swap size you should have, let’s first quickly know a thing or two about swapmemory. This will help you understand why swap is used.
The explanation has been simplified for (almost) everyone’s understanding.
What is swap? When is swap used?
Your system uses Random Access Memory(aka RAM) when it runs an application. When there are only a few applications running your system manages with the available RAM.
But if there are too many applications running or if the applications need a lot of RAM, then your system gets into trouble. If an application needs more memory but entire RAM is already in use, the application will crash.
Swap acts as a breather to your system when the RAM is exhausted. What happens here is that when the RAM is exhausted, your Linux systemuses part of the hard disk memory and allocates it to the running application.
That sounds cool. This means if you allocate like 50GB of swap size, your system can run hundreds or perhaps thousands of applications at the same time? WRONG!
You see, the speed matters here. RAM access data in the order of nanoseconds. An SSD access data in microseconds while as a normal hard disk accesses the data in milliseconds. This means that RAM is 1000 times faster than SSD and 100,000 times faster than the usual HDD.
If an application relies too much on the swap, its performance will degrade as it cannot access the data at the same speed as it would have in RAM. So instead of taking 1 second for a task, it may take several minutes to complete the same task. It will leave the application almost useless. This is known as thrashing in computing terms.
In other words, a little swap is helpful. A lot of it will be of no good use.
Why is swap needed?
There are several reasons why you would need swap.
If your system has RAM less than 1 GB, you must use swap as most applications would exhaust the RAM soon.
If your system uses resource heavy applications like video editors, it would be a good idea to use some swap space as your RAM may be exhausted here.
If you use hibernation, then you must add swap because the content of the RAM will be written to the swap partition. This also means that the swap size should be at least the size of RAM.
Avoid strange events like a program going nuts and eating RAM.
Do you need swap if you have lots of RAM?
This is a good question indeed. If you have 32GB or 64 GB of RAM, chances are that your system would perhaps never use the entire RAM and hence it would never use the swap partition.
But will you take the chance? I am guessing if your system has 32GB of RAM, it should also be having a hard disk of 100s of GB. Allocating a couple of GB of swap won’t hurt. It will provide an extra layer of ‘stability’ if a faulty program starts misusing RAM.
Can you use Linux without swap?
Yes, you can, especially if your system has plenty of RAM. But as explained in the previous section, a little bit of swap is always advisable.
In fact, a distribution like Ubuntu automatically creates a swap file of 2 GB in size. This should give you an indication that having some swap space is recommended.
Don’t worry if you didn’t create a swap partition while installing Linux. You can always create swap file in Linux at any time.
Recommended Read
Swap files allow you to create and use swap space on the fly in Linux. You can easily create them, resize them or delete them as per your need.
Size of RAM + 2 GB if RAM size is more than 2 GB i.e. 5GB of swap for 3GB of RAM
Ubuntu has an entirely different perspective on the swap size as it takes hibernation into consideration. If you need hibernation, a swap of the size of RAM becomes necessary for Ubuntu.
Otherwise, it recommends:
If RAM is less than 1 GB, swap size should beat least the size of RAM and at most double the size of RAM
If RAM is more than 1 GB, swap size should be at least equal to thesquare root of the RAM size and at most double the size of RAM
If hibernation is used, swap size should be equal to size of RAM plus the square root of the RAM size
Confused? I know it is confusing. This is why I have created this table that will give you the Ubuntu recommended swap size based on your RAM size and hibernation need.
RAM Size
Swap Size (Without Hibernation)
Swap size (With Hibernation)
256MB
256MB
512MB
512MB
512MB
1GB
1GB
1GB
2GB
2GB
1GB
3GB
3GB
2GB
5GB
4GB
2GB
6GB
6GB
2GB
8GB
8GB
3GB
11GB
12GB
3GB
15GB
16GB
4GB
20GB
24GB
5GB
29GB
32GB
6GB
38GB
64GB
8GB
72GB
128GB
11GB
139GB
How much swap size do you use?
The answer is never simple. As I stated earlier, for a long time, swap has been recommended to be of double the size of RAM. In fact my Dell XPS 13 Ubuntu edition has 16GB of swap size for an 8GB of RAM. So even Dell decided to go with the golden rule of swap=2xRAM.
What swap size do you prefer for your Linux system?
Normally your system will get soooo slow once it has to swap out even only 2GB that it's barely usable any more, so you would go exit some applications anyway. So 2GB plus a bit extra to be safe should be enough.
For more modern systems (>1GB), your swap space should be at a minimum be equal to your physical memory (RAM) size "if you use hibernation", otherwise you need a minimum of round(sqrt(RAM)) and a maximum of twice the amount of RAM.
Swap usage is often associated with system performance problems because the majority of the time high swap usage occurs during and after the server has run low on memory.
To clear the swap memory on your system, you simply need to cycle off the swap. This moves all data from swap memory back into RAM. It also means that you need to be sure you have the RAM to support this operation. An easy way to do this is to run 'free -m' to see what is being used in swap and in RAM.
Swap space will be useful for systems with less amount of RAM but it is never a replacement for RAM. Swap space resists on hard drives which have slower access time than physical memory. Once the RAM is used up, the swap space gets used. Since swap is slower than RAM, the performance of the system goes down.
For a long time, the recommended swap size was double of the RAM size but that golden rule is not applicable to modern computers anymore. ... How much should be the swap size?
10yr 1GB and 2GB have the same performance, the only difference is the memory which is used mostly when hooking it up to an external monitor. Although some say that certain games use alot of VRAM aswell such as BF3 and that the 2GB performs better on such games so it may be something to research and consider aswell.
YES!you can install a 2gb and 4gb RAM chip together. As long as the frequency is the same there isn't going to be any issues. However, if you add 2gb 1066 and 4gb 1600 the system will read the 2gb and 4gb has 1066.
A basic installation needs around 10G of disk space, if you add your own data you should be needing at least 20G of disk space. If you don't store personal files (music, movies, photos), 20G would suffice.
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB. Using this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap.
Usually, the minimum swap file size is 1.5 times the RAM capacity and the maximum is 4 times the RAM. For example: RAM = 1 gigabyte (GB) Minimum swap file = 1.5 GB.
Generally, we recommend 8GB of RAM for casual computer usage and internet browsing, 16GB for spreadsheets and other office programs, and at least 32GB for gamers and multimedia creators.
The swap partition serves as overflow space for your RAM. If your RAM fills up completely, any additional applications will run off the swap partition rather than RAM. This may sound like an easy way to increase your computer's amount of usable memory without actually getting more RAM, but that isn't the case.
If your disks arn't fast enough to keep up, then your system might end up thrashing, and you'd experience slowdowns as data is swapped in and out of memory. This would result in a bottleneck. The second possibility is you might run out of memory, resulting in wierdness and crashes.
Another way to increase the swap size is to use the GParted partition Editor. In short, you resize the swap partition, then right click on it and choose "Swapon". You must be able to increase the size of swap partition only if there is an unallocated space present before or after the swap partition.
It offers a slower access time compared to RAM and located in the disk memory. Swap space is actually a part of the virtual memory. There are several applications of swap space. It stores the applications which the OS doesn't use frequently.
The short answer is, No. There are performance benefits when swap space is enabled, even when you have more than enough ram. Update, also see Part 2: Linux Performance: Almost Always Add Swap (ZRAM). …so in this case, as in many, swap usage is not hurting Linux server performance.
At inception, the aggregate cash flows are an asset to the company, so the bank's credit spread is used to calculate the discount factor. The fair value of the interest rate swap is then calculated by multiplying the risk-adjusted discount factor and the net cash flows.
An amortizing swap is an interest rate swap where the notional principal amount is reduced at the underlying fixed and floating rates. An asset swap is a derivative contract through which fixed and floating investments are being exchanged.
According to Linus Torvalds, “all the normal distributions set things up with swap partitions, not files”. In addition, “swapfiles tend to be slower and have various other complexity issues.”
If the swap was used often, then the SSD may fail sooner. This might be why you heard it could be bad to use an SSD for swap. Modern SSDs don't have this issue, and they should not fail any faster than a comparable HDD.
If you don't want to use a swap partition, you can use a swap file: a filesystem image stored on a regular file and used as your swap space. The following articles explain how to do it in detail: Linux Add a Swap File – Howto. How to use hibernation without a swap partition (this also uses a swap file)
8GB is best for most users compared to 4GB because it provides enough RAM for most applications, tasks, and less demanding games. Many of the most commonly used applications don't have much RAM. However, it is common for users to run many applications at once.
It is recommended to have an equal amount of swap space as you do RAM. You can feel free to assign 8GB if you wish; however, this is not as applicable today as it was in the past when RAM was more expensive and some processes ran in swap space. In 4GB there is 2^32 bytes which is 4,294,967,296.
Because of the way memory fits into your laptop or computer, it's actually quite easy to remove and expand. One of the most common ways to upgrade your RAM is to replace your 4GB strips with 8GB strips, giving you a total 16GB.
16GB is the recommended amount of RAM for playing most games and will provide a noticeable increase in performance from 8GB. You will also be able to run applications in the background without affecting gameplay.
DDR5 or GDDR5 has more memory bandwidth and memory clock speed, which is why it is used for gaming purpose than DDR3. DDR5 is only used in graphics cards, on the other hand DDR3 is also used in computers. Despite the low latency of DDR3, DDR5 provides better performance than DDR3.
Gigabit Internet literally means that you are downloading 1,000,000,000 bits per second or 1,000 megabits per second. That's 100 times faster than the average Internet speed in the United States.
A 64-bit system can access 264 different memory addresses, i.e actually 18-Quintillion bytes of RAM. In short, any amount of memory greater than 4 GB can be easily handled by it.
2GB is enough to get some work done, like running your productivity suite and having plenty of open browser tabs, but you'll still be held back significantly in terms of running more powerful software solutions.
You should be fine with just 2 or 4 Gb of swap size, or none at all (since you don't plan hibernating). An often-quoted rule of thumb says that the swap partition should be twice the size of the RAM.
32GBs plenty of space for installing, but suggest getting an external drive for placing the home partition and/or a data partition if you think you will download a lot.
You'll need a PC with at least 512MB of RAM, and around 2GB of disk space. A Pentium 4 or later is recommended, although some older CPUs can run Arch Linux.
ABC Company and XYZ Company enter into one-year interest rate swap with a nominal value of $1 million.ABC offers XYZ a fixed annual rate of 5% in exchange for a rate of LIBOR plus 1%, since both parties believe that LIBOR will be roughly 4%. At the end of the year, ABC will pay XYZ $50,000 (5% of $1 million).
This is the reason why swapping is also referred to as memory compaction. ... Now we will calculate how long it will take to transfer from main memory to secondary memory.
Virtual memory is a combination of RAM and disk space that running processes can use. Swap space is the portion of virtual memory that is on the hard disk, used when RAM is full.
While the contents of these files may resemble or originate from volatile data, the page/swap file is nonvolatile and is preserved in its last operating state when power is removed.
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM.
We know that using Linux swap space instead of RAM (memory) can severely slow down performance. So, one might ask, since I have more than enough memory available, wouldn't it better to delete swap space? The short answer is, No.
Linux requires very little memory to run compared to other advanced operating systems. You should have at the very least 8 MB of RAM; however, it's strongly suggested that you have at least 16 MB. The more memory you have, the faster the system will run.
Without swap, the OS has no choice but to keep the modified private memory mappings associated with those services in RAM forever. That's RAM that can never be used as disk cache. So you want swap whether you need it or not. In that case, you don't need a swap file.
To clear the swap memory on your system, you simply need to cycle off the swap. This moves all data from swap memory back into RAM. It also means that you need to be sure you have the RAM to support this operation. An easy way to do this is to run 'free -m' to see what is being used in swap and in RAM.
You should be fine with just 2 or 4 Gb of swap size, or none at all (since you don't plan hibernating). An often-quoted rule of thumb says that the swap partition should be twice the size of the RAM.
It offers a slower access time compared to RAM and located in the disk memory. Swap space is actually a part of the virtual memory. There are several applications of swap space. It stores the applications which the OS doesn't use frequently.
The file swaps a section of RAM storage from an idle program and frees up memory for other programs. By using a swap file, the computer can use more memory than is physically installed. In other words, it can run more programs than it could run with just the limited resources of the installed RAM.
About: Manjaro Linux is a fast, desktop-oriented operating system based on Arch Linux. The distro provides all the benefits of cutting-edge software to get started quickly and automated tools to minimise manual intervention. It is completely free and is available for 64 Bit architectures. Know more here.
As long as your server and applications are performing as expected, you don't need to worry too much about it. The load average values should be within 75% of the number of CPUs. If a server has 4 CPUs, then 75% of 4 is 3. The load average values should not exceed 3 in that case.
Is 64/128 GB of RAM Overkill? For the majority of users, it is. If you plan on building a PC purely for gaming and some general, basic, everyday activity, 64 GB of RAM is just too much. The amount of RAM you need will ultimately depend on your workload.
1024 MB is the total system memory available, which would be physical RAM. 1 MB and 823 MB both show free because an application has access to both for memory storage.
Introduction: My name is Arline Emard IV, I am a cheerful, gorgeous, colorful, joyous, excited, super, inquisitive person who loves writing and wants to share my knowledge and understanding with you.
We notice you're using an ad blocker
Without advertising income, we can't keep making this site awesome for you.