10

I have done several searches and I cannot find anything on Google about why but arch has allocated 7.7 gigs to ram and 7.9 to swap.

  • I only have 8 gigs ram.

  • it allocated more ram to swap than regular

How could I change the allocations?

output of cat /proc/meminfo: MemTotal: 8091960 kB MemFree: 4925736 kB MemAvailable: 6131188 kB Buffers: 268936 kB Cached: 1219460 kB SwapCached: 0 kB Active: 1527516 kB Inactive: 1301140 kB Active(anon): 768904 kB Inactive(anon): 711440 kB Active(file): 758612 kB Inactive(file): 589700 kB Unevictable: 32 kB Mlocked: 32 kB SwapTotal: 8300540 kB SwapFree: 8300540 kB Dirty: 1960 kB Writeback: 0 kB AnonPages: 1306968 kB Mapped: 382800 kB Shmem: 140100 kB Slab: 197964 kB SReclaimable: 163104 kB SUnreclaim: 34860 kB KernelStack: 6864 kB PageTables: 29200 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 12346520 kB Committed_AS: 3927808 kB VmallocTotal: 34359738367 kB VmallocUsed: 0 kB VmallocChunk: 0 kB HardwareCorrupted: 0 kB AnonHugePages: 186368 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 584316 kB DirectMap2M: 7716864 kB DirectMap1G: 0 kB

  • 21
    swap is, by definition, not using RAM. – user4556274 Aug 14 '16 at 22:45
  • 1
    The same (or a little bit more) swap then you got RAM is a good start... Also remember that swap-space may be used if you hibernate (put RAM to disk). In the old days, one said twice as much swap as RAM - but for Linux, that "rule" only applied when you had 512MB or less (or was it 256MB). There were however Unix-systems (at least one) where the design was such that you always had to have at least twice the amount of swap. Early Linux had limits on how much swap per partition, number of swap-partitions and/or total swap. TBC – Baard Kopperud Aug 15 '16 at 0:10
  • 2
    Continued... To really decide how much swap you need, you really should carefully audit how much memory the processes you (and your users) run actually need - but remember that swap is no substitute for too little RAM. That said - and this from somebody who only got 2GB (not "only" 8GB like you) RAM - most systems will be able to keep all processes in RAM. However they don't need to, so swap is used to store "unused" memory-pages of processes - and sometimes whole "unused" processes - thus freeing up RAM... this "unused" RAM, is then used as buffer and cache, to speed up things. – Baard Kopperud Aug 15 '16 at 0:17
  • 2
    The 7.7GB number probably comes from ~300MB of physical RAM having been permanently allocated to the kernel. That RAM still exists but can't be used for ordinary programs. – zwol Aug 15 '16 at 0:49
  • 1
    What leads you to believe "Arch thinks you have 16GB RAM"? – marcelm Aug 15 '16 at 13:25
26

What this is telling you is that you have 16GB of virtual memory.

Virtual memory is the total of physical RAM and swap space added up.

It's a way of letting your system run more programs than it physically has the space for.

How much swap should be allocated to a machine is a complicated and opinionated question; ask 2 people and get 3 answers :-)

Your setup isn't bad, and I wouldn't recommend making changes to it until you learn a lot more about how virtual memory works and how to tune it. It's a good starting point.

  • 5
    "Virtual memory is the total of physical RAM and swap space added up." No, it's not. For example, on a 64-bit machine with 4GB of RAM and 4 GB of swap, I can memory map a 64GB file. That's 64GB of virtual memory, even though RAM and swap add up to 8GB. – David Schwartz Aug 15 '16 at 9:30
  • 1
    @DavidSchwartz is correct. It's more proper to say that virtual memory is what can be addressed as memory, preferably with something backing it. That something can be either RAM chips, some I/O port, a swap partition, a swap file on disk, or a regular file with no special meaning to the operating system or memory manager. It's also not required to function in such a way that if you write something and then immediately read it back, you read back what you wrote. (For instance some I/O registers function in this way.) – a CVn Aug 15 '16 at 11:44
  • 1
    It's the "Unix 101 beginners version". I also didn't mention how executable pages can be added as read-only pages to the memory map and other fun things like overallocation. As a first level approximation, however, VM=RAM+swap is close enough, and is all this question was really about. – Stephen Harris Aug 15 '16 at 12:43
  • "What this is telling you is that you have 16GB of virtual memory." - There's no way to know that since the OP has never explained why he thinks Arch says he has 16GB. – marcelm Aug 15 '16 at 17:51
  • 1
    @StephenHarris It's first level approximations that cause the misunderstanding behind this question. Simplifications are fine, so long as they either indicate that they are simplifications or are factually correct. – David Schwartz Aug 15 '16 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.