PHP objects and their size

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

PHP objects and their size

Post 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 :)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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...
(#10850)
Post Reply