Let’s Know All About Memory (2)
Posted in category: Computer and Hardware at: January 2, 2012 by adminWhen a program opens it first allocates some memory for its own needs. For example. If you open a 1000 bytes essay file with Microsoft Word 2007, from a floppy disk, and edit it (i.e you change the word JOHN into PAUL) the changes are not made to the essay file on the floppy disk. They are made inside memory instead, to avoid wear of the floppy disk. If you imagine every time you edited an essay character (byte value) the whole essay file had to be re-saved onto floppy disk you would soon end up with a damaged floppy disk. Just changing JOHN into PAUL would mean four re-saves. Memory is purposely made for the constant editing of byte values.
When Microsoft Word 2007 opens an essay file from floppy disk for example it first allocates (reserves) 1000 bytes of file memory, so it can store an exact copy of the essay file inside that memory – The original essay file on the floppy disk is left intact. The next thing Microsoft Word 2007 does is allocate some memory for its editing needs. For example. If you make a copy of the word JOHN, because you want to add (paste) it somewhere else in the essay, behind the scenes Microsoft Word 2007 makes a copy of the word JOHN by storing the word JOHN inside the edit memory. So you now have 1000 bytes full of essay characters inside the file memory and 4 bytes used inside the edit memory for the J O H N characters. However. Because you might want to copy a paragraph, an whole essay page or even the whole essay Microsoft Word 2007 has to make sure it has allocated enough edit memory for these situations. The same applies to the file memory – It might not be allocated just 1000 bytes for the essay characters, but perhaps 3000 bytes just in case you need to add more to the essay (i.e you start copying bits out of an History/Research file into the essay or you just type more characters into the essay). So the essay might need 5000 bytes in total allocated for it. Once you have finished editing the essay, which is in file memory at this point, you then tell Microsoft Word 2007 to save the file memory back onto the floppy disk as an essay file.
A collection of bytes is known as Data. Microsoft Word 2007 sees files and memory as a block of data only, which means when it opens a file and copies it into memory all it is doing is copying a block of data from one place (i.e Floppy Disk) to another (i.e Memory). So when it saves the essay file from file memory to floppy disk it just sees it as copying a block of data from one place to another. And that is how you should see files and memory – as blocks of data. Once the essay (file memory) has been saved onto the floppy disk as an essay file the file memory and edit memory are released for other programs to use.
The above is okay when everything is running smoothly, but problems arise when a program tries to allocate memory that is not available. For example. If you try to open too many programs or files at once they might crash (Freeze/Stop) Windows Vista. This would be due to the programs either not having enough memory to open themselves (i.e show their own windows) or not enough memory for their additional needs, such as editing files. For example. If there are only 10,000 bytes of memory remaining and two newly opened programs are waiting for 50,000 bytes of memory each they will be put in a waiting queue. Waiting forever. Or at least until another program closes and releases its memory, but it might only be releasing 4000 bytes of memory. In which case one of the waiting programs could use the 4000 bytes now available and then wait for the other 46,000 bytes to become available. On the other hand, the programs might get sick of waiting and decide to close. Either way it is a slow and messy process. This is why you should get to know the limits of your computer first before opening too many programs at once. Another scenario is memory corruption. Basically this is when a program misinterprets some byte values. For example. If a language program is supposed to read 74, in a settings file, as English but sees (reads) 77 instead. It would probably show text in a different language – Not much harm as you could probably change the language setting back to English once the language program had opened and fully completed. However. Imagine if a program interprets a byte value of 100 to mean you have paid/registered to use that program and a byte value of 101 to mean you are just trying out that program for 30 days. You might of paid £30 for a program that is saying you have not paid, but you are just trying it out. Incidently. This is one way hackers hack legal software…they change the software’s data (byte values) so it thinks the user has paid for it. Apart from hacked bytes data is normally corrupted because the files (software/programs) came from a bad/scratched floppy disk or CD – The files can still be read as data (byte values), but as incorrect data. Unfortunately, a program will not test every byte value inside a file simply because it would take too long, especially if it was a large file.
