Page 1 of 1

PHP objects and their size

Posted: Sun Oct 28, 2007 8:24 pm
by alex.barylski
A few times I've listened in on disscussions AKAPJ has had about PHP and it's object support and how objects blow up in size the minute you start adding member variables...

I'm curious as to why this would be the case - I cannot for the life of me think how a member variable would be any more taxing on a system than a global variable.

As far as I know at least technically there is only an additional 4 byte integer used to conatin the *this* pointer...why is it an object in PHP explodes in size (according to AKAPJ - at least this is the impression I was under) - but globals are not as taxing?

Cheers :)

Posted: Sun Oct 28, 2007 9:00 pm
by Christopher
I believe it is when you add methods, not properties, that objects start getting larger. Where is PJ to grouse about objects and set us straight? ;)

Perhaps those inclined to such things could run some memory usage tests on object from classes that have various numbers of properties and methods...