Home > Article > Software Tutorial > Will adding a memory stick to a computer make it faster? Must read: Adding memory will make a computer faster, the answer is finally revealed
php editor Strawberry unveiled a controversial question: "Will adding a memory stick to a computer make it faster?" After in-depth research and experiments, we finally revealed the answer. Adding more RAM really does make your computer faster! Memory is an important component in a computer for storing and processing data, and its size directly affects the performance of the computer. By increasing memory, your computer can run programs and process tasks faster, improving overall speed and responsiveness. Next, we will explain in detail how memory affects computer performance and give some practical suggestions.
Let’s talk about a simple question today, will adding more memory make your computer faster?
To answer this question, we need to know the relationship between CPU, memory and program. It is actually very simple:
First, the executable program is stored on disk, including machine instructions and related data.
When the program is running, it is first loaded into the memory. The program loaded into the memory suddenly becomes what we call a process. Of course, there is another special program running in the memory: operation system.
Only when the CPU actually executes the machine instructions, the corresponding process starts to run. At this time, the CPU continuously fetches instructions from the memory and executes the instructions. Of course, in addition to the machine instructions, it also needs to read the data in the memory.
It can be seen that when the program is running, it is the memory rather than the disk that interacts with the CPU. Instructions and data are stored in the memory, and the CPU uses instructions and data. Therefore, from this perspective, this is a similar process between the producer and the disk. Regarding consumer issues, memory is like a chef and CPU is like a diner. If the chef serves food too slowly, the diners will starve.
In addition, the memory usage of the operating system cannot be ignored.
How does the operating system use memory?
To make full use of memory and disk resources, there are many very smart designs in modern operating systems.
Since the CPU can only run one program at a time, even in a multi-core system, generally the number of processes existing at the same time is far more than the number of cores, which means that not all programs are running at a certain moment. , even for a running process, due to the existence of the principle of locality, there will always be some instructions or data in the process address space that are temporarily unused.
Based on these, operating system pioneers saw the opportunity to make full use of memory. We can put instructions or data that are temporarily unused on the disk (swap out), and then use these data or instructions when they are used. Loading from disk to memory (swap in), so there is more space in memory to run more processes. This idea is called demand paging in the operating system and is part of virtual memory.
Secondly, the operating system will use the remaining free memory as a disk cache. Sometimes when the system load is low, our program cannot Make full use of memory, so is this free memory really useless? Obviously not. We know that the disk is a low-speed storage device. In this case, why not use the free physical memory as the cache of the disk?
Everyone may have this experience. When you start to open a brand new file, it is usually slower, but when you use the file again, you will obviously feel that the speed will be much faster. This is the principle behind it. If you have insufficient memory at this time, then the operating system does not have that much free memory to use as a disk cache, and you will truly experience the snail-like speed of the disk.
Now, we can answer the question we started with, will adding memory make the computer run faster? Obviously this discussion can be divided into two situations.
Enough memory
If your memory itself is sufficient, then adding more memory in this case will not make your computer run faster, because the speed of the CPU as a diner is limited, and the chef cooks the dishes No matter how much, you can't make diners eat faster.
This is like asking if adding more wheels to a truck will make the truck go faster?
The answer is obviously no. Although this does not make the truck go faster, adding more wheels will allow the truck to carry a higher load.
The same is true for memory. Although adding more memory will not make the computer run faster, it will obviously make it We can run more programs simultaneously.
Adding more memory means you can open more browser web pages at the same time, start more virtual machines at the same time, render more high-definition videos at the same time, process more complex 3D models at the same time, and train more at the same time. Machine learning models, etc. At this time, your memory is not the bottleneck, but the CPU will most likely become the bottleneck, because the running speed of the CPU, that is, the number of machine instructions executed per second, is limited.
Insufficient memory
At this time, the chef's serving speed is too slow and the diners are always hungry, so the chef needs to serve more dishes.
We know that most programs will frequently apply for memory during operation. Applying for memory is a seemingly simple task. Very complex operations, especially when the system has insufficient memory, apply for memory at this time and often involve more complex searches or exception handling. At this time, our program running speed will be significantly slower.
When there is insufficient memory, there may be more exchanges between the disk and the memory. At this time, the speed of the system will be limited by the disk, and since disk files cannot be cached, the speed at which we start processes or open files will be Noticeably slower.
In this case increasing the memory will feed the CPU better and therefore will significantly speed up the computer.
Summary
From the above analysis, we know that whether increasing memory can speed up the computer depends on your scenario. If your device has sufficient memory, then increasing memory at this time will not significantly speed up the computer.
The above is the detailed content of Will adding a memory stick to a computer make it faster? Must read: Adding memory will make a computer faster, the answer is finally revealed. For more information, please follow other related articles on the PHP Chinese website!