Re: [PHP] Re: PHP memory usage

2003-01-03 Thread Rick Widmer
At 01:25 AM 1/3/03 -0200, Fernando Serboncini wrote:



function a(myclass c)
{
return c;
}

would create another copy of c in memory. Things get a bit larger when you
go with linked-list like structures in classes, where you have to take
really good care to don't duplicate data. If you're not taking care, then
maybe 5MB is normal.



Not really.  PHP has its own method of handling variables which does not 
make a copy of data unless it has to.  See:

   http://www.zend.com/zend/art/ref-count.php


This may be the most important paragraph in the article:

   Note that PHP 4 is not like C: passing variables by reference is not
   necessarily faster than passing them by value. Indeed, in PHP 4 it is
   usually better to pass a variable by value, except if the function
   changes the passed value or if a reference is being passed.


Rick


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP memory usage

2003-01-02 Thread Fernando Serboncini
I don't know if I'm talking bullshit, but don't forget that each parameter
or return valeu in php, if not explicited as a pointer, it's a copy of the
full parameter.
This way, any

function a(myclass c)
{
return c;
}

would create another copy of c in memory. Things get a bit larger when you
go with linked-list like structures in classes, where you have to take
really good care to don't duplicate data. If you're not taking care, then
maybe 5MB is normal.

IMHO, I agree with splitting the class into smaller functions. 370KB is a
big thing, that maybe useless. PHP isn't Java so you're not suposed to do a
class mysite

[]s
Fernando

James H. Thompson [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 We have a good size PHP libary -- about 370KB of source code.
 Its one class with a multitude of small functions in it.
 just doing a require_once() on this library appears to use about 5MB of
 memory.(the change in VmSize in /proc/self/status)

 Is this a  normal ratio of PHP source code size to executable size?


 --
 Jim

 James H. Thompson
 [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php