LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-12-2022, 03:06 PM   #1
Michael Piziak
Member
 
Registered: Feb 2015
Distribution: Ubuntu 20.04 lts
Posts: 598

Rep: Reputation: 43
Where is "memory cache" stored at?


I was using "system monitor" and noticed that it said "Cache 2 gb"

I understand this is where sets of instructions are stored that are often used a lot by the computer. I would like to know if this 2 GB of cache is on my actual memory modules (ram) in my computer or is it somewhere else - like on the mother board?

See screenshot attached.

Regards,

Michael

Addendum: Perhaps someone could also explain "swap" memory that I see also. I this HD space that is pretending to be memory?
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2022-04-12 16-03-27.png
Views:	24
Size:	65.1 KB
ID:	38765  

Last edited by Michael Piziak; 04-12-2022 at 03:07 PM.
 
Old 04-12-2022, 03:25 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,665
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Purposely deferring your question about "cache," I will now address your second question about "swap."

"Virtual storage" operating systems such as Linux present the illusion to running processes that they own a certain amount of "memory." But they take advantage of a characteristic of running programs known as "locality of reference." That is: "the next memory-reference that will be made by this process is likely to be nearby to its previous one(s)." This enables the OS to use hardware magic to keep within physical memory only those portions of storage that the process is actually right-now using. Anything else can be "swapped out" to external storage, to then be "swapped in" on-demand, possibly "swapping out" something else to make room. The hardware magic arranges things so that the process is never aware. When the process tries to "touch" anything that is not resident in memory, a so-called "page fault" hardware interrupt occurs, which enables the OS to "swap in" the missing information – and the running process is none the wiser.

At this time, the "storage" that has been allocated to running processes exceeds the amount of physical RAM available by about 1.0GB.

Last edited by sundialsvcs; 04-12-2022 at 03:30 PM.
 
2 members found this post helpful.
Old 04-12-2022, 03:26 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,650

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by Michael Piziak View Post
I was using "system monitor" and noticed that it said "Cache 2 gb"
I understand this is where sets of instructions are stored that are often used a lot by the computer. I would like to know if this 2 GB of cache is on my actual memory modules (ram) in my computer or is it somewhere else - like on the mother board?
Yes...memory actually does refer to your memory modules, which would seem obvious. And why, exactly, does it matter where it's located??? If you're that curious, it's odd that you did no research at all into what it is, since that would also explain where it is.
Quote:
Addendum: Perhaps someone could also explain "swap" memory that I see also. I this HD space that is pretending to be memory?
This link should provide some hints: https://gprivate.com/5yv3t
 
1 members found this post helpful.
Old 04-12-2022, 05:52 PM   #4
Michael Piziak
Member
 
Registered: Feb 2015
Distribution: Ubuntu 20.04 lts
Posts: 598

Original Poster
Rep: Reputation: 43
Quote:
Originally Posted by sundialsvcs View Post
Purposely deferring your question about "cache," I will now address your second question about "swap."

"Virtual storage" operating systems such as Linux present the illusion to running processes that they own a certain amount of "memory." But they take advantage of a characteristic of running programs known as "locality of reference." That is: "the next memory-reference that will be made by this process is likely to be nearby to its previous one(s)." This enables the OS to use hardware magic to keep within physical memory only those portions of storage that the process is actually right-now using. Anything else can be "swapped out" to external storage, to then be "swapped in" on-demand, possibly "swapping out" something else to make room. The hardware magic arranges things so that the process is never aware. When the process tries to "touch" anything that is not resident in memory, a so-called "page fault" hardware interrupt occurs, which enables the OS to "swap in" the missing information – and the running process is none the wiser.

At this time, the "storage" that has been allocated to running processes exceeds the amount of physical RAM available by about 1.0GB.
Thanks.

Will the amount of "swap" memory decrease as one increases the physical memory/ram of the computer?
Also, if swap memory is on the HD, isn't it slower?

Last edited by Michael Piziak; 04-12-2022 at 05:54 PM.
 
Old 04-12-2022, 06:31 PM   #5
Soadyheid
Senior Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,672

Rep: Reputation: 486Reputation: 486Reputation: 486Reputation: 486Reputation: 486
Quote:
Will the amount of "swap" memory decrease as one increases the physical memory/ram of the computer?
The "swap memory" is actually a swap partition on your hard drive. It's size is usually the same size as the physical memory you have installed as it can also be used when you want to hibernate your system (Put it to sleep) rather than shut it down. The physical memory image is copied to the swap partition to enable the system to restart from where it was put to sleep. The physical volatile memory will be shut down with the rest of the system. When it's woken up, the memory image can be reloaded into physical memory and you can continue with what you were doing.

The swap partition is also used as a location for core dumps when/if your system crashes. (I think)

Quote:
if swap memory is on the HD, isn't it slower?
Yes, if you're running too many memory intensive tasks you will be swapping out and in lots of data and accessing a hard disk is slower than accessing physical memory. (The info can only be accessed each time the data passes under the read head while spinning) More physical memory is always a good thing to prevent what's known as page thrashing - pages of memory being swapped out and in from the HDD. Slows the system and shortens the disks life.

Think of the swap partition as "Virtual" memory.

That's my

Play Bonny!


Last edited by Soadyheid; 04-12-2022 at 06:33 PM.
 
1 members found this post helpful.
Old 04-12-2022, 06:39 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,650

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by Michael Piziak View Post
Thanks.
Will the amount of "swap" memory decrease as one increases the physical memory/ram of the computer?
Since you loaded Linux, did you skip the part where you partitioned the disk, and had to allocate space for swap, or at least see it?? How, exactly, would putting more RAM in your computer repartition your disk??
Quote:
Also, if swap memory is on the HD, isn't it slower?
Obviously. But it's rarely used these days, except for certain circumstances. Again, odd that none of your own research into these things turned up much, or that you can't seem to apply things. Odd for a 'scientist'.
 
Old 04-12-2022, 08:25 PM   #7
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,332
Blog Entries: 28

Rep: Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144
OP might find this article from the kernel documentation helpful.
 
Old 04-12-2022, 08:45 PM   #8
Michael Piziak
Member
 
Registered: Feb 2015
Distribution: Ubuntu 20.04 lts
Posts: 598

Original Poster
Rep: Reputation: 43
Thanks everyone.

I remember, like over 10 years ago, I could control the virtual memory of an old Macintosh - have the HD act like it was physical memory. Was definitely slower.

My desktop has 16 gigs ram and I don't recall it having any "swap" memory show up in "system monitor." I'm away from home and using my Laptop and really just noticed it having like 2 gigs of swap memory in system monitor - the laptop only has 6 gigs Ram.

My desktop, that I increased to 16 gigs, really was an overkill at adding that much memory. I've never seen it try to use over 3 or 4 gigs of ram. The most intensive things I do is probably process photos in Gimp. The laptop, though, having 6 gigs ram, I think it could maybe use a couple more gigs ram.

Thanks everyone...
 
Old 04-12-2022, 09:05 PM   #9
Michael Piziak
Member
 
Registered: Feb 2015
Distribution: Ubuntu 20.04 lts
Posts: 598

Original Poster
Rep: Reputation: 43
Quote:
Originally Posted by frankbell View Post
thank you for the link, i am reading and learning it now
 
Old 04-13-2022, 12:35 AM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Also see:
https://www.linuxatemyram.com/
 
Old 04-13-2022, 01:00 AM   #11
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,235

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
This should hopefully be a helpful contribution:

https://unix.stackexchange.com/quest...ds-in-top-mean
 
Old 04-13-2022, 12:59 PM   #12
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,665
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Basically, every process runs in a "virtual memory" environment, which uses a built-in CPU featured called dynamic address translation (DAT) to present to the process a picture of "what 'memory' looks like" which is blissfully unaware of the existence of any other process – unless it has chosen to "share a memory segment." The addresses generated by the running process are translated to corresponding physical addresses ... or, if the requested information is "not in memory," causes a "page fault" hardware interrupt which passes control to the Linux kernel while the running process is unaware. Linux then "resolves" the problem by bringing in the requested "page" of data, at which time the process can resume and now the data will be there. (A "page fault" will not happen a second time.)

Linux is entirely responsible for doling-out the "physical RAM" resource, and it considers both the physical availability of that resource and the constantly-changing demand for it. Obviously, if you've bought "plenty of physical RAM" ... and you should, because "chips are cheap" now ... Linux will perceive much less need to "swap things out in order to make room to swap things in."

If you'd been a PhD student in the 1970's, you might have been the grad student whose thesis first talked about "Locality of Reference." This is the observation that the next memory reference made by a running process is most-likely to be nearby to one of its recent ones. As long as you design your program to do that – and most "container classes" are already aware of it – your process will run with very little delay caused by "page faults."

If you do not abide by this rule, you can experience the horrors of "thrashing," otherwise known as "hitting the wall." The performance of your process, which up to that point had been degrading linearly, suddenly degrades exponentially, and generally begins to take the rest of the system down with it. "It is not a pretty sight ..."

Last edited by sundialsvcs; 04-13-2022 at 01:04 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
where is cache stored in caching only dns server in linux raj k yadav Linux - Newbie 1 09-28-2014 08:19 AM
[SOLVED] how to find that we have problem with the cache memory when I have 2 cache and 3 proc rpittala Linux - Newbie 1 02-02-2012 03:46 PM
[SOLVED] Access/Print a C Variable "as it is stored in the memory" paliga Programming 14 10-25-2010 11:06 AM
Help With Java Problem Please"""""""""""" suemcholan Linux - Newbie 1 04-02-2008 06:02 PM
how is cache stored in mozilla? gajaykrishnan Programming 2 08-13-2004 09:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration