I understand content length to be the size of an object in byte e.g. 1 byte or 1024bytes, etc however what is data length? Not sure whether it is language specific but if it is I would like to know how it applies to PHP and ASP.NET
-
1In what context are you seeing "content length" and "data length"? – pete Feb 15 '12 at 02:38
-
@pete - When attempting to download a file. – PeanutsMonkey Feb 15 '12 at 04:02
1 Answers
For object size you can use memory_get_usage() as per the linked answer.
For file size you can use filesize();
EIDT: in line with updated query.
As per your comment on the question you'd be looking for filesize(), I think.
- File size is the amount of space on a storage device which is occupied by a given flie.
- Object size is the amount of RAM that the object consumes while it is instantiated.
Imagine a sheet of paper with ten numbers on it and enough space to write another ten or so. As long as you don't edit the text on the sheet of paper its contents will remain the same regardless of whether or not you can see or even interact with the sheet of paper.
Now imagine you need three of these numbers for a task, you've (as an example) the capacity to remember a sequence of up to five numbers, so you memorise the sequence. Once you've carried out the task you required the sequence for it can be discarded from (your) memory to free up space. Once the sequence has been freed from memory (object destroyed) you will no longer be able to recollect it or similarly if you experience an unexpected life exception, say knock yourself out and you forgot the sequence, the sheet of paper does not.
-
What is the difference between object size and file size? Sorry if I am being a n00b but thought they were the same thing. – PeanutsMonkey Feb 15 '12 at 04:01
-
-
Thanks SOliver. That's a great example although am blurry what happens after an Object has been instantiated and its completes its task. Is the amount of RAM allocated to it discarded at the end of the event? – PeanutsMonkey Feb 15 '12 at 18:49
-
No worries; I've reworded the answer which should be a bit clearer. In Php an object is [destroyed](http://php.net/manual/en/language.oop5.decon.php) when either the __destruct() method is called or there are no references to the object. – CBusBus Feb 15 '12 at 21:09
-
When you say "you will no longer be able to recollect it or similarly if you experience an unexpected life exception, say knock yourself out and you forgot the sequence, the sheet of paper does not" what do you mean by "the sheet of paper does not". Do you mean to say that the "sheet of paper" does not? – PeanutsMonkey Feb 16 '12 at 00:46