You know, reading your post was a little difficult, but got the idea. but you know what...I like the criosity, since Im like that too 😀
Ok, Creating a new file (test.txt) = 0 B, 0B on disk.
Create new file + one char = 1 B, 4 KB on disk. 😀
......till......
I ran some tests by using MS-DOS debug:
I created a new file text.txt with this written: 'blah bl' That is 7 bytes, space included!
Running debug in DOS.
D:\>debug test.txt
-r
AX=0000 BX=0000 [B]CX=0007[/B] DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=137C ES=137C SS=137C CS=137C IP=0100 NV UP EI PL NZ NA PO NC
137C:0100 37 AAA
-
Here look at the CX register, = 0007 which is actual space used by the file in memory. i.e 7 bytes!
Now I will dump the contents of the file test.txt. You can see blah bl written.
-d
137C:0100 62 6C 61 68 20 62 6C 00-00 00 00 00 00 00 00 00 blah bl.........
137C:0110 00 00 00 00 00 00 00 00-00 00 00 00 34 00 6B 13 ............4.k.
137C:0120 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
137C:0130 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
137C:0140 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
137C:0150 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
137C:0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
137C:0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
Jus avoid the 4 k written there, I still am trying to figue that out. No, its not the 4 k like in 4KB, i had over written it, nothing happened! See below.
Here i will create a file with exactly 4096 B (4 KB) in debug and save it.
-f 100 1000 32
-d
137C:0100 32 32 32 32 32 32 32 32-32 32 32 32 32 32 32 32 2222222222222222
137C:0110 32 32 32 32 32 32 32 32-32 32 32 32 32 32 32 32 2222222222222222
137C:0120 32 32 32 32 32 32 32 32-32 32 32 32 32 32 32 32 2222222222222222
137C:0130 32 32 32 32 32 32 32 32-32 32 32 32 32 32 32 32 2222222222222222
137C:0140 32 32 32 32 32 32 32 32-32 32 32 32 32 32 32 32 2222222222222222
137C:0150 32 32 32 32 32 32 32 32-32 32 32 32 32 32 32 32 2222222222222222
137C:0160 32 32 32 32 32 32 32 32-32 32 32 32 32 32 32 32 2222222222222222
137C:0170 32 32 32 32 32 32 32 32-32 32 32 32 32 32 32 32 2222222222222222
-n c:\test2.txt
-w
-rcx
CX 02FB
:1000
-n c:\test2.txt
-w
Writing 01000 bytes
-
Here, ' Writing 01000 bytes' is in HEX which means 4096 in decimal. Ok, we have created a file of exactly 4 KB 😀. Now, when I checked the properties it said,
4KB size, 4KB size on disk. No change!
Well, let me add one more byte to the file to make it 4097 bytes.
After doing that the properties:
Size: 4.00 KB (4,097 bytes)
Size on Disk: 8.00 KB (8,192 bytes)
Observation:
When you cross the allocated file size (I think this is a standard in NTFS), then it allocates the next block,
4 more KB! So, windows actually goes on increasing 4KB after it crosses the next limit... 4KB, 8KB, 12KB etc.
THIS WAS FOR .TXT or TEXT FILES!
IED Kid, you were right in observing, diff comps have different allocation methods, I think this might depend on windows file system used like NTFS or FAT32 etc.