Jump to content

Where can i learn about SWAP?

Jae Tee

Anyone know a good place where i can learn about swap and its relation to ram?

 

Links please if allowed, preferably YouTube.

At me or quote me, I want to hear your opinion.

 

Hopefully anything I say is factually correct. Sorry for any mistakes in advanced.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Are we talking about linux?

 

Got any thing you want to know in specfic?

 

Read this https://wiki.archlinux.org/index.php/Swap

 

Go play with it on a system.

 

Basically it is used when there isn't enough ram or if pages aren't used very often, and nernel decides cache would be a better use of ram(can be tweaked)

Link to comment
Share on other sites

Link to post
Share on other sites

 

5 minutes ago, Electronics Wizardy said:

Are we talking about linux?

 

  .snip.

IDK, I actually only heard it first in linux. From the little bit i know, if I have enough RAM I don't actually want it? Does this make sense? 

At me or quote me, I want to hear your opinion.

 

Hopefully anything I say is factually correct. Sorry for any mistakes in advanced.

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Jae Tee said:

 

IDK, I actually only heard it first in linux. From the little bit i know, if I have enough RAM I don't actually want it? Does this make sense? 

Whats your setup? What are you running software wise?

 

Normally you want to have swap. It keeps stuff from being killed from out of memory, and moves stuff that isn't being used to disk, so you get a bigger drive cache.

Link to comment
Share on other sites

Link to post
Share on other sites

Technically, no, "you don't want swap". But, unless you have an abundance of RAM, you "do want swap". lol.

 

You "don't want it" because SSD's (or harddrives, omg you don't want SWAP on harddrives these days), are much slower than RAM. So going to swap slows things down. But to negate going to SWAP, you need an excessive amount of RAM depending on the situation. My Ubuntu VM's on my homelab have anywhere from 768 MB to 2.5 GB of RAM. They rarely go to SWAP, and if they do they use on the order of single digit MB. But they are headless, and not doing much... so not much to SWAP out anyways.

 

That wasn't a very technical answer, but I am sure google could help out more anyways.

Rig: i7 13700k - - Asus Z790-P Wifi - - RTX 4080 - - 4x16GB 6000MHz - - Samsung 990 Pro 2TB NVMe Boot + Main Programs - - Assorted SATA SSD's for Photo Work - - Corsair RM850x - - Sound BlasterX EA-5 - - Corsair XC8 JTC Edition - - Corsair GPU Full Cover GPU Block - - XT45 X-Flow 420 + UT60 280 rads - - EK XRES RGB PWM - - Fractal Define S2 - - Acer Predator X34 -- Logitech G502 - - Logitech G710+ - - Logitech Z5500 - - LTT Deskpad

 

Headphones/amp/dac: Schiit Lyr 3 - - Fostex TR-X00 - - Sennheiser HD 6xx

 

Homelab/ Media Server: Proxmox VE host - - 512 NVMe Samsung 980 RAID Z1 for VM's/Proxmox boot - - Xeon e5 2660 V4- - Supermicro X10SRF-i - - 128 GB ECC 2133 - - 10x4 TB WD Red RAID Z2 - - Corsair 750D - - Corsair RM650i - - Dell H310 6Gbps SAS HBA - - Intel RES2SC240 SAS Expander - - TreuNAS + many other VM’s

 

iPhone 14 Pro - 2018 MacBook Air

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Jae Tee said:

IDK, I actually only heard it first in linux. From the little bit i know, if I have enough RAM I don't actually want it? Does this make sense? 

There's no harm in having some swap, your system won't use it unless there's a reason to use it. Even my server has some swap; most of the time, the server is using RAM for, you know, web-servers, Plex, file-sharing and so on, so it moves the GUI-stuff into swap, thereby giving all the useful stuff some more RAM. Then, if I had to go and use the GUI on it, it'd load the GUI-stuff back from swap into RAM.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, Electronics Wizardy said:

Whats your setup? What are you running software wise?

 

Normally you want to have swap. It keeps stuff from being killed from out of memory, and moves stuff that isn't being used to disk, so you get a bigger drive cache.

currently im on windows with 16 gb of ram dual channel. I dont really do much heavy work aside from gaming. other than that its either web browsing (I always close unused tabs) or running simple programs, be it specifically or windows background stuff.

At me or quote me, I want to hear your opinion.

 

Hopefully anything I say is factually correct. Sorry for any mistakes in advanced.

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Jae Tee said:

currently im on windows with 16 gb of ram dual channel. I dont really do much heavy work aside from gaming. other than that its either web browsing (I always close unused tabs) or running simple programs, be it specifically or windows background stuff.

With that use case, leave it to the default unless there is a problem. Playing with swap normally comes much more into play when your ram limited or running servers.

Link to comment
Share on other sites

Link to post
Share on other sites

11 hours ago, Jae Tee said:

Anyone know a good place where i can learn about swap and its relation to ram?

 

Links please if allowed, preferably YouTube.

I'll see if I can explain this in a clear manner.

 

Way back when, RAM was expensive but people wanted to run more and more apps. To help alleviate an issue with not having enough RAM, OSes started to store data from RAM on the storage drive if it wasn't being used. The action of moving data back and forth between RAM and storage is called "swapping." This is useful in some cases, but if there's a constant amount of swapping going on, the system will start coming to a crawl as transferring data to and from storage is exceptionally slow.

 

To support this feature, the concept of "virtual memory space" was created wherein the OS can make applications believe there's more memory than what's physically available. This helps simplify the app development process now because the apps don't have to know how much physical memory (RAM) is available. The OS knows and all the application has to do is make requests from "virtual memory". The OS handles translating these requests from virtual memory space to physical memory space. In Windows (Linux and others may be the same), virtual memory space is basically how much RAM you have plus how much in storage was allocated to swapping (this shows up in C:\ as a file named pagefile.sys).

 

Of note, you can get away with running your computer without storage space allocated to swapping, but this presents a few problems:

  • Some applications actually refuse to run if no storage space was allocated
  • When applications want a chunk in memory space, the OS will often give the application more than what was requested. The idea is that the application will likely want more memory in the future and so it's to prevent the application's data from being all over the place in memory space. However, until the application uses it, the OS won't mark the memory as "in-use", only reserved.

    The problem with not having storage space allocated is when applications made enough reservations that it takes up all of the physical RAM. So the next time an application wants more memory, the OS goes "sorry, can't do that" and the application likely throws an "out of memory" error. When there's storage space allocated, the OS can shuffle the reserved portions to storage without much of a hiccup since there's no data on them to begin with.

If you look at Windows' Task Manager -> "Performance" tab -> Memory page, if you look at the "Committed" value, that tells you how big your system's virtual memory space is and it tells you the total of how much memory all the applications have at least reserved.

 

EDIT: tl;dr OSes allocate space in storage to dump stuff from RAM into if the data isn't being used. Swapping is transferring data in and out.

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, Mira Yurizaki said:

I'll see if I can explain this in a clear manner.

 

   .snip.

So if I have this right: assuming I have enough, sufficient, or more likely lots of extra RAM, for a slightly better performance, I dont want to use swap.

 

Does this make sense? And if so, how can i have control over this (preferably windows, but also linux)? 

At me or quote me, I want to hear your opinion.

 

Hopefully anything I say is factually correct. Sorry for any mistakes in advanced.

 

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, Jae Tee said:

So if I have this right: assuming I have enough, sufficient, or more likely lots of extra RAM, for a slightly better performance, I dont want to use swap.

You don't want a condition where the computer is constantly swapping. However, having storage allocated to virtual memory space allows you to have less RAM than you would actually need to contain what you need virtual memory space wise. There's a balancing act between having too little RAM and just enough so you're not in a constant-swapping condition.

 

Otherwise, you're going to need a lot more physical RAM than you actually would use if you want to run without allocating storage space and without running into an issue where you've ran out of virtual memory space, which doesn't imply all of it is actually being used.

 

9 minutes ago, Jae Tee said:

Does this make sense? And if so, how can i have control over this (preferably windows, but also linux)? 

In Windows it's in Control Panel -> System and Security -> System -> "Advanced system settings" on the left pane -> "Settings" button in the "Advanced" tab > Performance section -> Advanced tab -> Virtual Memory

 

I don't know what it is in Linux.

 

However I'd advise to leave these settings alone. If you're not having a problem, there's nothing to fix.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×