Asked by Ryan
Why adding only characters to a text file may increase the file's size by several hundred bytes and at other times may not increase the file's size at all?
Answers
Answered by
MathMate
You are probably looking at the directory listing. Some list them as the real size, some list them as what has been assigned. Operating systems do not assign one byte at a time when the file needs to expand. Space is assigned in blocks, of which a common size is 512 bytes.
So as long as the content of the file does not exceed the last assigned block, the file size does not increase. Once it is exceeded, the operating system will assign an extra block of 512 bytes, thus your observation.
So as long as the content of the file does not exceed the last assigned block, the file size does not increase. Once it is exceeded, the operating system will assign an extra block of 512 bytes, thus your observation.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.