Matt, It's true that the difference might be minimal but we've worked hard to improve the memory manager over the past couple of years where many of these improvements where minimal that added up. I see no good reason to use this less accurate method of checking how much memory is being consumed by the script for something other than debug. Therefore, I think the community is better served to make that functionality a bit slower and having an always enabled, fast and accurate memory limit.
Andi > -----Original Message----- > From: Matt W [mailto:[EMAIL PROTECTED] > Sent: Friday, July 28, 2006 4:08 AM > To: internals@lists.php.net; Dmitry Stogov; 'Andi Gutmans' > Subject: Re: [PHP-DEV] memory_get_usage with new Memory Manager > > Hi Dmitry, > > No, there's always more work going on (with > --enable-memory-limit) with every emalloc() call to update > the size even when real_size isn't updated, right? Meaning > > heap->size += true_size; > if (heap->peak < heap->size) { > heap->peak = heap->size; > } > > at the end of _zend_mm_alloc_int(), etc. memory_get_usage() > changes after adding a variable, for example, so I think > there's updating even < 128 bytes -- isn't a variable around > 56 bytes? sizeof(zval) + sizeof(Bucket)? > That actually uses 2 small emalloc() calls... > > I'm just trying to show that there wouldn't be a performance > hit if the memory usage functions are always enabled... My > comparison was worst case, I think, since even if the usage > functions are always available, some of the stuff can still > be in #if MEMORY_LIMIT (checking against limit, etc.). > > I'm saying there appears to be no real penalty for *always* > keeping track of mem usage (for memory_get_[peak_]usage()). > You know that in my tests, one was compiled with > --enable-memory-limit, and the other wasn't (verified by > checking if memory_get_usage() was available). > > > Thanks, > Matt > > > ----- Original Message ----- > From: "Dmitry Stogov" > Sent: Friday, July 28, 2006 > > > Hi Matt, > > In case of small size (size <= 128B), your code fit into > special case, those handled by allocator's cache. > The memory_usage information isn't updated in this case. > > 128B < size < 256KB - uses zend memeory manager and updates > memory_usage information. > Seems it works with the same speed. > > size >= 256KB - utilizes system storage manager > (malloc/mmap/...) and checks memory limit. > > Dmitry. > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php