-3

Does having swap space makes sense if I have a 32 bit OS (Linux) and 4 GB RAM already?

As it would have to be addressable with a 32 bit address, which are already all "used up" by the RAM, would swap even be accessible to the operating system?

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
  • 4
    Your question is identical to this one on Super-User: http://superuser.com/questions/592783/does-the-4-gb-ram-limit-on-32-bit-systems-also-affect-the-swap-space Thanks, EBrown – Der Kommissar Feb 26 '15 at 17:00
  • Cross-site dupe: http://superuser.com/questions/592783/does-the-4-gb-ram-limit-on-32-bit-systems-also-affect-the-swap-space – AStopher Feb 26 '15 at 19:36
  • Thanks a lot for redirecting to the superuser.com answer. I wasn't aware that this is a end-user question. BTW: I am a bit uneasy about getting 3 minus points for that question anyway. That is hard, and really disencourages from asking anything anywhere. – user2081279 Mar 02 '15 at 13:44

1 Answers1

2

Of course. Why wouldn't it? I think the more relevant question is whether or not using a 32 bit OS makes sense these days, but I digress.

First, yYou're under the mistaken impression that 32 bit operating systems can only address 4 GB of memory, which isn't actually the case. 32 bit systems can address more than 4 GB of memory through the use of Physical Address Extension (PAE), and in Linux, this has been supported since kernel version 2.3.23, allowing up to 64 GB of memory to be addressed. So, actually, having 4 GB of RAM isn't particularly relevant.

Furthermore, when you consider what swap is, it almost always makes sense to have swap. Swap is just virtual memory, and virtual memory came about because of the fact that RAM has historically been more expensive than disk storage. In essence, it is a solution to make computing more cost effective by limiting the amount of relatively expensive RAM that software requires by letting some relatively cheap disk space be used to store memory contents, instead of requiring everything be held in RAM. At a high level, all that swap or virtual memory is, is a memory location that's slower than RAM, but faster than reading from a random part of the disk, like you do with a temporary file. As a result, operating systems use virtual memory to store memory contents they don't expect to need, or don't expect to need "soon." It's basically like a waiting room for memory contents.

Because this solution has worked so well, general computing operating systems (which "Linux" is) expect virtual memory to be available, and while it usually can be disabled, there's almost never a good reason to. Even if your operating system has more memory than it needs, there's basically no downside to letting it store infrequently accessed data in virtual memory, and in the vast majority of cases, there's no benefit to disabling virtual memory, which has been standard in operating systems for ages - why change something when you don't get any benefit from the change?

So, in summary, it almost always "makes sense" to have swap, both because 32 bit operating systems can and do address more than 4 GB of memory, and because of what swap is - a location for infrequently accessed data that's slower than RAM, but faster than random disk.

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208