Re: [PHP-DEV] huge memory usage in concat op, ZE2

2002-12-09 Thread Tom Fishwick
yup, works for me, thanks andi.

Andi Gutmans <[EMAIL PROTECTED]> wrote: 
> 
> Tom,
> 
> This should be fixed now. Please update your Zend CVS and let me know if it 
> works for you.
> 
> Andi
> 
> At 08:06 PM 12/8/2002 -0800, Tom Fishwick wrote:
> >I was reading an email from stdin.  But regardless of bad coding style
> >:-), the script is using _way_ more memory than it should.
> >
> >$s = '';
> >while(strlen($s) < 266768) {
> > $s.= 'd';
> >}
> >
> >this code uses 151Megs on my system. the same code uses about 2megs with
> >php4.3.  php4.3 seems to realloc/memcpy when the string gets big, and
> >php5 just does malloc's and memcpy's (I don't see calls to free()
> >though).  I'm thinking the problem might be in zend_mm_realloc?
> >
> >Tom
> >
> >Andi Gutmans <[EMAIL PROTECTED]> wrote:
> > >
> > > At 12:30 AM 12/8/2002 -0800, Tom wrote:
> > > >hey there,
> > > >
> > > >I'm using the cvs and ZE2, there seems to be some huge memory usage when
> > > >concatenating a string to a length over 262080 bytes, when the string
> > > >length gets to that size the malloc call inside
> > > >zend_mm_add_memory_block starts grabing memory 262168 bytes at a time,
> > > >every 8th concatenation (i'm concatenating 1 byte at a time).
> > > >
> > > >anyone else seen this?
> > >
> > > It makes sense that this is happening to you. Reaching the point where you
> > > add to a string of such size is very bad coding practice (unless you 
> > really
> > > have no choice). This is because if the memory manager can't realloc() (it
> > > very often can't) then it'll have to allocate a new block and use a
> > > memcpy() to copy over all of the string.
> > > The current code is less than optimal in this case and I can choose 
> > various
> > > strategies to improve on it but there will always be times where the
> > > malloc()/memcpy() will be necessary.
> > > So what are you doing? Is it something you have to do?
> > > Andi
> > >
> > >
> > > --
> > > PHP Development Mailing List <http://www.php.net/>
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
> >--
> >PHP Development Mailing List <http://www.php.net/>
> >To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> -- 
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] huge memory usage in concat op, ZE2

2002-12-08 Thread Tom Fishwick
I was reading an email from stdin.  But regardless of bad coding style
:-), the script is using _way_ more memory than it should.

$s = '';
while(strlen($s) < 266768) {
$s.= 'd';
}

this code uses 151Megs on my system. the same code uses about 2megs with
php4.3.  php4.3 seems to realloc/memcpy when the string gets big, and
php5 just does malloc's and memcpy's (I don't see calls to free()
though).  I'm thinking the problem might be in zend_mm_realloc?

Tom

Andi Gutmans <[EMAIL PROTECTED]> wrote: 
> 
> At 12:30 AM 12/8/2002 -0800, Tom wrote:
> >hey there,
> >
> >I'm using the cvs and ZE2, there seems to be some huge memory usage when
> >concatenating a string to a length over 262080 bytes, when the string
> >length gets to that size the malloc call inside
> >zend_mm_add_memory_block starts grabing memory 262168 bytes at a time,
> >every 8th concatenation (i'm concatenating 1 byte at a time).
> >
> >anyone else seen this?
> 
> It makes sense that this is happening to you. Reaching the point where you 
> add to a string of such size is very bad coding practice (unless you really 
> have no choice). This is because if the memory manager can't realloc() (it 
> very often can't) then it'll have to allocate a new block and use a 
> memcpy() to copy over all of the string.
> The current code is less than optimal in this case and I can choose various 
> strategies to improve on it but there will always be times where the 
> malloc()/memcpy() will be necessary.
> So what are you doing? Is it something you have to do?
> Andi
> 
> 
> -- 
> PHP Development Mailing List 
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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




[PHP-DEV] caller function?

2001-02-10 Thread Tom Fishwick

hi people,

I was just wondering if the caller() function is being worked on?  I
have this application that's about 6000 lines of php code, and aprox,
1/4 done.  I've been starting to put in my methods stuff like

if(get_class($foo) != 'foo'))
trigger_error('$foo is not of type foo',E_USER_ERROR);

and it would be _awesome_ for the trigger_ function to be able to say
who called it.  Or do a stack trace or something.

thanks,
Tom

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]