Pages

Sunday, 2 October 2011

SIZE DOES MATTER

Among the very first things that we have learned in our school days while using computer is, to create new file. Our instructors used to tell us how to do that by right clicking the mouse button. And our excitement used to reach peak to fill that file with garbage.

But, over the time we used to wonder why there are two sizes for single file. If you are not aware of the reason behind this then keep reading.

Let's do simple exercise.
1. Right click mouse button and create some text file anywhere on your machine.
2. Add "abcd" to this file and save it.
3. Now, right click again and check the properties. You will find two infirmation related to size.

Size : 4 bytes
Size on disk: 4K (4,096 bytes) (This may vary depending on your computer settings which we will discuss later.)

The first size value that you see is obvious one. It's the total size of the characters you typed in your file. The second size i.e.  Size on disk is creating the thrill.

Now let's understand the reason.

Everyone might have taken some quantity of grains to flour mill at least once in a life time. (If not, then hats off to your wife or mother :) ). Well, let's say you are preparing for some event in your house and your mother or your wife has containers filled with 1Kg  of Pigeon pea & 4 Kg  of wheat for you to take it for grinding. Let's assume that both the containers can carry maximum 5 Kg of the quantity. So, here
1 Kg  & 4 Kg are the value of Size and 5 Kg is the value of Size on disk .

Putting the above paragraph in techical terms, replace Mother/Wife with OS, container with file and ingredients in container with contents in the file. Every OS has to manage the memory in the system. So, it creates fixed sized page. So, everytime you create some new file you are actually allocating a page. On my lappy, a page has size of 4 KB. And that's what we see as "Size on disk". This obviously means that if the contents of the file goes above 4KB (4096 bytes), OS is going to allocate another page for you. Thus you see two sizes. You may have page size of 1 KB.



No comments:

Post a Comment