Re: Instantiation of class objects

From: Date: Thu, 21 Dec 2000 22:58:11 +0000
Subject: Re: Instantiation of class objects
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-42088@lists.php.net to get a copy of this message
On Thu, 21 Dec 2000, szii wrote: > I'm not sure if this is PHP related, or more Zend related, but > I'll post it here first. > > When instantiating new objects, the Zend engine doesn't > seem to be caching them. Ie, we run a PHP page which > calls new on an object. Then we shutdown the socket and > do it again..and again...and again. > > The times do not decrease (as I would expect with caching) > and doing exactly the same functionality WITHOUT using > a formal class nets us 100% increase in speed. This is > WITH the bware caching - turning it off makes no > difference either. That "new" allocater seems heinously > expensive. > > It was my assumption that the Zend engine did garbage > collection and would re-use objects in it's cache prior > to making expensive memory allocation calls. Bad > assumption? > > TIA! > > -Szii > It can't tell if the object(s) you're instantiating are going to be used the same way, or for the same thing, or what, and AFAIK there's no surefire way of reinitializing old objects, so there's no point in caching them. Are you sure that it's new that's slowing it down, and not in fact just OO overhead? Try using new for the heck of it in the procedural version, then use the procedures instead. OOP does have overhead, so it may not be new on its own. -- Ignacio Vazquez-Abrams <ignacio@openservices.net>

« previous php.dev (#42088) next »