Zend core object creation

From: Date: Fri, 29 Jun 2001 23:27:49 +0000
Subject: Zend core object creation
Groups: php.general 
Request: Send a blank email to php-general+get-55612@lists.php.net to get a copy of this message
Okay, perhaps I need to spend some more time studying language compilers/interpreters, but I've got a question regarding object creation in the PHP core. Basically, what, internally, is part of a PHP object (class instantiation)? I know Zend started using reference counting a while back, so I guess all objects are basically references, but I need to know how much of the class information is contained in the objects themselves. So if I have a class like so: class foo { var $var1; var $var2; var $var3; function func1() { ... } function func2() { ... } function func3() { ... } } and instantiate it like so: $foo1 = new foo; will the internal representation of the $foo object contain definitions for all the variables and functions? So that when I make a second object: $foo2 = new foo; will its internal representation duplicate all those method definitions? My guess is that the most efficient implementation would be to have some sort of class template that holds, at the least, definitions for the methods, so that every instantiation refers to those method definitions in the static template instead of storing their own method definitions. Variables, since they can't be referenced statically in PHP, would have to be stored in the object itself; methods, however, could simply be implemented analogously to functions that take an object as their first method (i.e., like functions that operate on structs in C). Any ideas? If you prefer, could you direct me to where in the source to look for an answer? The reason I'm worried about all this is that I'm writing a very large application, and I have to worry about object creation time and memory resources because I may have many distinct objects of the same type instantiated at the same time. Thanks. Dean.

« previous php.general (#55612) next »