Is there a difference between SWAP and Cache memory?

14,076

Yes. They are a complete different thing, even the opposite in a lot of ways. I will try to explain both simply and short. Note that this answer are just a simplification and the real thing is quite more complex. Click on the wikipedia links for a better explanation.

  • Disk Cache memory: This are chunks of the physical memory, the RAM, used to store files. That way when a program needs to read the file, it's fetched from memory instead of the hard disk. This is done because memory is way faster.
  • Swap: This is a place on the hard disk (usually a dedicated partition) that is used to store programs or data that can't fit in memory, like when a program grows more than the available memory. SWAP is way slower than RAM, so when you hit swap the computer gets slower, but at least the program can work. In linux swap is also used to hibernate, or to move low used program out of memory to allow more space to the disk cache.
Share:
14,076

Related videos on Youtube

mloman
Author by

mloman

I'm an Ubuntu newbee. Please be gentle. Started with 10.04. Just recently migrated to 11.10

Updated on September 18, 2022

Comments

  • mloman
    mloman over 1 year

    I installed the indicator-multiload 0.2-0ubuntu1 from the software center. (It's very similar to the gnome panel indicator showing memory and CPU graphs)

    When I click on the Unity panel which shows the little memory graph, it says ;

    Mem :1.451 GB Cache: 2.581. This is also represented in the color graph.

    However, when I load the System Monitor, SWAP is at a flat 0.

    Is this normal, or could there be a bug in either the System Monitor or Panel Indicator?

  • jobin
    jobin about 10 years
    Also, you have a fair control over the amount of Swap area your system(Operating system) can use; you can increase or decrease the amount of memory allowed using various tools like gparted. On the other hand, the amount of cache in your hardware is fixed; the processor manufacturer, like Intel or AMD has manufactured the processor to work with a fixed amount of cache memory.
  • jan
    jan over 6 years
    @jobin: You are talking about processor cache, but Javier and mloman were referring to disk cache