MBytes
New member
Ok guys. Glad you are interested.
Before I start, they are some things to know:
- A running program (app, game, etc) is called a process. That is the correct terminology.
- A process is fully on RAM (system memory).
- The main processor (CPU - Central Processing Unit) can ONLY access, read, write on your RAM. It has no access to your hard drive or solid state drive, or anything else. That is why a process needs to be on RAM.
- To locate things on the RAM, everything is allocated with addresses, from 0, to the max amount of RAM you have OR the maximum address length your CPU can get.
So if you have a 32-bit CPU that would be 0 to 2^32 (4294967296 ~ 4GB of RAM). Now you know why 32-bit CPU can't address more than 4GB of RAM. (Ok well, they are trick and tricks to by-pass this restrictions with the OS that support this ability, but that is out of scope for this explanations. But if you are really interested, get a book on Operating System Design, however please note that you need prior knowledge of Computer Architecture, another book to get and read before.)
- Stuff placed in RAM cannot be moved. You'll understand bellow why that is the case.
- Also note that this is very complicated, and I am trying my best to make it as simple as possible. So, please bear with me. It may require a second read.
So a program, as we know, is a long set of instructions for the processor. It includes everything that the program does, and including how to draw itself (which either the CPU or the GPU (graphical processing unit) will handle). Now, as it's set of instructions which the processor executes, there is no names to identify things. For example, there is no name "replyTextBox" for the reply box on this forum that I am using right now to post this... well post. All it is, is memory addresses. For example, as I am typing this post on the reply box of the forum, I am entering data in address 94462191 on the server of the forum being hosted (ok well, in reality: a) I don't know that address value... I am pulling a number from my ***, for the sakes of example, and b) I am actually entering the data on MY system RAM, and will be on the server RAM, once I hit the "Post Reply" button, which the server will then follow its instructions, which is to write it on the forum database).
Now, the addresses that a program refers DOES NOT represent the location of the system RAM. As each program have their addresses start at 0. So, if I have multiple processes, they will conflict (program B will execute instructions of program A, when I click on Save button in a program.... what a mess that would be). The way it works, is that when we execute a program, the main processor will load the program to RAM at a free spot, and says: Well the program is at position 25646000 address. So I'll add "25646000" to all the values of the program. So, if there is a reference to address 100, it will be 25646100. Simple. Now we can have multiple processes on our system without any conflicts or issues. And that is also why, a process in RAM can't be moved... the CPU is using it! Imagine filling up a form, where you can't move, and then I come and turn the pages on you, where you'll definitely write at the wrong spot, and psychically move the form on you, write what you are trying to write everywhere and not where you are supposed to. So we can't move things.
Knowing the above, you can see that there is no way that the processor can split a program in RAM into parts. I mean it COULD be possible (anything is possible), but it will be VERY costly to implement and provides 0 performance increase, nor decrease... as RAM is so freaking fast, it can access data in a micro seconds. And that is NOT a bottleneck. So it just cost heavy amount of money for no good reason. Much like SSD's (Solid state drives) the reason why fragmenting provide 0 performance boost, is that it can get all the pieces together in no time (milliseconds. Slower than RAM, as SSD chips are MUCH slower, and they are other bottlenecks in the way)
So, RAM content is never fragmented. All processes are in full blocks in our RAM. So all these "defrag your RAM", "optimize your RAM" programs are 100% bogus... what's to defrag? It’s already defragmented! Beside, even if we had.... for the sakes of argumentation, fragmentation, getting all the pieces cost microseconds. And in reality... there is nothing to even get...because the program on RAM will just refer to other memory address that is simply further down the RAM, so it's like if it was all together. :grin: So no matter how you turn things in an imaginary situation... fragmentation provides 0 performance decrease on RAM.
What we have however, is open fragmentation. That is we have a bunch of empty spots free in our RAM, around programs on RAM, where a new program that we want to load, can't fit in 1 block, despite having the space as in total of all the free spots together.
View is this way:
- Process A consumes 10% of your RAM.
- Process B consumes 40% of your RAM.
- Process C consumes 5% of your RAM.
- Process D consumes 30% of your RAM.
- Process E consumes 5% of your RAM.
- 10% Free space after Process E to the end of your memory.
Total: 90% used, 10% free.
Now, you close Process C. So now, as nothing can move, you have a 5% free space hole in your RAM. In total, you have 15% of free space. Great!
Now, you open Process F, which consume 15% of your RAM. Well you are out of RAM. Because, while you have the space, it doesn't fit into 1 block. Remember nothing can move. You have fragment free space. So you get a low memory error, despite having plenty of free space.
What normally happens in such situation is that Windows (or whatever OS you use), flushes out the RAM clean. Then it copies the pagefile to your RAM in an organize way (defragmented) back the RAM. Your page file is not only an extension of your RAM, in the case you are out of RAM, but also a backup of your RAM. Everything you put on your RAM is duplicated on your page file directly. The reason for this, is to make this open space defragmentation, be performed the fastest as possible. Else, it would need to copy the RAM to your HDD or SSD and then flush it, and copy the page-file back to the RAM, and we know how much time it takes transferring several GB of data, it sure isn't instant especially using an HDD.
But why the backup? I can wait! You say. Well it's because, anything that isn't in your RAM, can't be processed by the CPU. So, your system will temporally lock up, as your RAM will be emptied. Now Windows (well Vista and up) is smart. To hide this, it will first priorities key component of the OS, related to the user interface and your interaction with the system, by transferring that, first onto your RAM, this will make it invisible to you as it’s just a few MB and everything else will follow, with some fancy algorithm on what you are currently using, and other guess work. Pretty smart. Well it's more complicated than that... But that's the essential idea.
In the old, old, days back when we had 128/256MB of RAM with XP or older, you might recall that your system, after starting a program, just becomes unresponsive for a moment (temporarily freezes), and comes back to normal. When this occurred, your system was doing this open space fragmentation.
So now you know why you should not disable page file, because if you do, and you start a new program and it doesn't fit in 1 block, well the program won't run, but rather crash at startup, and Windows will tell you "You are low in virtual memory", and then you'll open the Task Manager and look how much RAM you have free, and start scratching your head how come its a problem, while you do have the free space. The open space defragmentation process for your RAM can't occur.
I hope this makes it understandable of how things are going behind the scenes a bit in a brief way, at least for that aspect. If you know how it all works behind, then you'll see the price of Windows as free, as it's super complicated and huge amount of challenges to rectify and solve. And now you understand why Microsoft requires several thousands of engineers to work just on Windows, for many years. 'cause without an OS... your system is just circuit boards stuck together, that doesn't do much.
Well hope you found this helpful.
Before I start, they are some things to know:
- A running program (app, game, etc) is called a process. That is the correct terminology.
- A process is fully on RAM (system memory).
- The main processor (CPU - Central Processing Unit) can ONLY access, read, write on your RAM. It has no access to your hard drive or solid state drive, or anything else. That is why a process needs to be on RAM.
- To locate things on the RAM, everything is allocated with addresses, from 0, to the max amount of RAM you have OR the maximum address length your CPU can get.
So if you have a 32-bit CPU that would be 0 to 2^32 (4294967296 ~ 4GB of RAM). Now you know why 32-bit CPU can't address more than 4GB of RAM. (Ok well, they are trick and tricks to by-pass this restrictions with the OS that support this ability, but that is out of scope for this explanations. But if you are really interested, get a book on Operating System Design, however please note that you need prior knowledge of Computer Architecture, another book to get and read before.)
- Stuff placed in RAM cannot be moved. You'll understand bellow why that is the case.
- Also note that this is very complicated, and I am trying my best to make it as simple as possible. So, please bear with me. It may require a second read.
So a program, as we know, is a long set of instructions for the processor. It includes everything that the program does, and including how to draw itself (which either the CPU or the GPU (graphical processing unit) will handle). Now, as it's set of instructions which the processor executes, there is no names to identify things. For example, there is no name "replyTextBox" for the reply box on this forum that I am using right now to post this... well post. All it is, is memory addresses. For example, as I am typing this post on the reply box of the forum, I am entering data in address 94462191 on the server of the forum being hosted (ok well, in reality: a) I don't know that address value... I am pulling a number from my ***, for the sakes of example, and b) I am actually entering the data on MY system RAM, and will be on the server RAM, once I hit the "Post Reply" button, which the server will then follow its instructions, which is to write it on the forum database).
Now, the addresses that a program refers DOES NOT represent the location of the system RAM. As each program have their addresses start at 0. So, if I have multiple processes, they will conflict (program B will execute instructions of program A, when I click on Save button in a program.... what a mess that would be). The way it works, is that when we execute a program, the main processor will load the program to RAM at a free spot, and says: Well the program is at position 25646000 address. So I'll add "25646000" to all the values of the program. So, if there is a reference to address 100, it will be 25646100. Simple. Now we can have multiple processes on our system without any conflicts or issues. And that is also why, a process in RAM can't be moved... the CPU is using it! Imagine filling up a form, where you can't move, and then I come and turn the pages on you, where you'll definitely write at the wrong spot, and psychically move the form on you, write what you are trying to write everywhere and not where you are supposed to. So we can't move things.
Knowing the above, you can see that there is no way that the processor can split a program in RAM into parts. I mean it COULD be possible (anything is possible), but it will be VERY costly to implement and provides 0 performance increase, nor decrease... as RAM is so freaking fast, it can access data in a micro seconds. And that is NOT a bottleneck. So it just cost heavy amount of money for no good reason. Much like SSD's (Solid state drives) the reason why fragmenting provide 0 performance boost, is that it can get all the pieces together in no time (milliseconds. Slower than RAM, as SSD chips are MUCH slower, and they are other bottlenecks in the way)
So, RAM content is never fragmented. All processes are in full blocks in our RAM. So all these "defrag your RAM", "optimize your RAM" programs are 100% bogus... what's to defrag? It’s already defragmented! Beside, even if we had.... for the sakes of argumentation, fragmentation, getting all the pieces cost microseconds. And in reality... there is nothing to even get...because the program on RAM will just refer to other memory address that is simply further down the RAM, so it's like if it was all together. :grin: So no matter how you turn things in an imaginary situation... fragmentation provides 0 performance decrease on RAM.
What we have however, is open fragmentation. That is we have a bunch of empty spots free in our RAM, around programs on RAM, where a new program that we want to load, can't fit in 1 block, despite having the space as in total of all the free spots together.
View is this way:
- Process A consumes 10% of your RAM.
- Process B consumes 40% of your RAM.
- Process C consumes 5% of your RAM.
- Process D consumes 30% of your RAM.
- Process E consumes 5% of your RAM.
- 10% Free space after Process E to the end of your memory.
Total: 90% used, 10% free.
Now, you close Process C. So now, as nothing can move, you have a 5% free space hole in your RAM. In total, you have 15% of free space. Great!
Now, you open Process F, which consume 15% of your RAM. Well you are out of RAM. Because, while you have the space, it doesn't fit into 1 block. Remember nothing can move. You have fragment free space. So you get a low memory error, despite having plenty of free space.
What normally happens in such situation is that Windows (or whatever OS you use), flushes out the RAM clean. Then it copies the pagefile to your RAM in an organize way (defragmented) back the RAM. Your page file is not only an extension of your RAM, in the case you are out of RAM, but also a backup of your RAM. Everything you put on your RAM is duplicated on your page file directly. The reason for this, is to make this open space defragmentation, be performed the fastest as possible. Else, it would need to copy the RAM to your HDD or SSD and then flush it, and copy the page-file back to the RAM, and we know how much time it takes transferring several GB of data, it sure isn't instant especially using an HDD.
But why the backup? I can wait! You say. Well it's because, anything that isn't in your RAM, can't be processed by the CPU. So, your system will temporally lock up, as your RAM will be emptied. Now Windows (well Vista and up) is smart. To hide this, it will first priorities key component of the OS, related to the user interface and your interaction with the system, by transferring that, first onto your RAM, this will make it invisible to you as it’s just a few MB and everything else will follow, with some fancy algorithm on what you are currently using, and other guess work. Pretty smart. Well it's more complicated than that... But that's the essential idea.
In the old, old, days back when we had 128/256MB of RAM with XP or older, you might recall that your system, after starting a program, just becomes unresponsive for a moment (temporarily freezes), and comes back to normal. When this occurred, your system was doing this open space fragmentation.
So now you know why you should not disable page file, because if you do, and you start a new program and it doesn't fit in 1 block, well the program won't run, but rather crash at startup, and Windows will tell you "You are low in virtual memory", and then you'll open the Task Manager and look how much RAM you have free, and start scratching your head how come its a problem, while you do have the free space. The open space defragmentation process for your RAM can't occur.
I hope this makes it understandable of how things are going behind the scenes a bit in a brief way, at least for that aspect. If you know how it all works behind, then you'll see the price of Windows as free, as it's super complicated and huge amount of challenges to rectify and solve. And now you understand why Microsoft requires several thousands of engineers to work just on Windows, for many years. 'cause without an OS... your system is just circuit boards stuck together, that doesn't do much.
Well hope you found this helpful.
Last edited: