In summary, this is such a massive oversimplification that it i misleading. There's a large chink of 'yes it used to be but we changed all that', principally because this describes a roll-in/roll-out mindset of the UNIX V7 of the early 1980s. On 05/03/2020 13:12, Richmond wrote:
When linux detects that you haven't used a program for some time, it will swap it out and use the memory for buffers.
No, no, ten thousand times no! Linux does not think of 'programs' when it comes to virtual memory, it thinks of pages. It manages memory by having a linked list of pages. The position on the queue is indicative of how long since the page was last accessed. Actually the are two LRU queues: one is for immutable pages the other is for mutable pages. Code is immutable. I don't think Linux has any self-modifying code, but who knows :-) Mutable pages are for data. I'm not sure how 'constants' are handled.
The increased use of buffers supposedly makes the system more efficient.
That's an old programming axiom, but what makes 'buffers' in this setup is 'otherwise usable' memory. In reality there is one big linked list of memory and the Tw0-LRU is done by pointers. So not all memory needs to be on those two lists. How much goes there? Well there are about 40 other vm 'tuning' settings to play with. And there is a sophisticated algorithm.
How much linux will swap out will depend on swappiness, NO! 'Swappiness' controls how aggressive the swapping is compared to actual memory. This is a setting which control what some people call Linux's "predictive swapping". Again, it gets into the swap algorithms. Set to high (even the default of 60 is high enough to case predictive/pre-emptive swapping) and it swaps everything out to start with, and then has to swap back in to run!
and also on the amount of swap available. Linux is aiming to have buffers, but also to have free memory in case it suddenly needs to do something. This is why you see it swapping when there is memory available.
No. In one sense the buffers are 'available' memory. They can be consumed if needed, but how much memory is kept for the operation system to use (the purpose of buffers) is again a VM tunable parameter. Swap-out of a page happens when a data page that has been modified ('marked as dirty') ages out. There's no point swapping out a code page, you can just drop old ones. The startup code that processes the command line is a good example of aged code that is no longer needed.
Whether you change swappiness depends on what you are doing. If you have two programs running and you are occasionally switching between them with alt-tab, then there will be long pauses while it swaps back in the program it swapped out while you were not using it.
No. You are describing a roll-in/roll-out approach. A virtual memory system is concerned with the 'working set' of code that is involved in the running of the system. In addition, Linux uses shared libraries! For a simple switching such as you describe to cause paging in a VM system there must be very little memory to start with.
You can check which programs are using memory by running 'top' and pressing M, then the highest memory users will be at the top. Shared memory doesn't necessarily count though.
Most people solve the problem by buying so much memory it doesn't matter.
Nonsense! "Virtual memory means virtual performance" was the idiom from the 1960s when IBM and others fist implemented virtual memory with little understanding for the algorithms! Back the a IBM/370 with 256K of memory was typical. Linux is more sophisticated and can always use the memory, somehow. -- A: Yes. > Q: Are you sure? >> A: Because it reverses the logical flow of conversation. >>> Q: Why is top posting frowned upon? -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org