Re: huge memory usage in concat op, ZE2

From: Date: Mon, 09 Dec 2002 08:40:05 +0000
Subject: Re: huge memory usage in concat op, ZE2
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-92233@lists.php.net to get a copy of this message
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 <andi@zend.com> 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


« previous php.dev (#92233) next »