|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-04-13 17:01 UTC] derick@php.net
[2005-04-13 20:16 UTC] jerome at kingofsofa dot org
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 00:00:02 2025 UTC |
Description: ------------ I think I have found a memory leak in php 4 and 5 depending on the size of the string concatenated to a variable a few bytes of memory are lost. See attached code. I have noticed that if you replace echo "instance $i "... by a "smaller" sentence echo "i $i " then the leak is not there. Since it has been there for a while I was wondering if this is actually an expected behavior. If so how should I do to avoid this. This is part of a script running constantly and calling some trace function that end up doing an echo. Reproduce code: --------------- for( $i = 0; $i < 100 ; $i++ ) { echo "instance $i ".memory_get_usage()."\n"; } echo "-------------------------------------------\n"; for( $i = 0; $i < 100 ; $i++ ) { echo "instance "; echo $i; echo " ".memory_get_usage()."\n"; } Expected result: ---------------- Content-type: text/html X-Powered-By: PHP/5.0.4 instance 0 40248 instance 1 40264 instance 2 40264 instance 3 40264 instance 4 40264 instance 5 40264 instance 6 40264 instance 7 40264 instance 8 40264 ... instance 99 40264 ------------------------------------------- instance 0 40264 instance 1 40280 instance 2 40280 instance 3 40280 instance 4 40280 instance 5 40280 instance 6 40280 Actual result: -------------- Content-type: text/html X-Powered-By: PHP/5.0.4 instance 0 40248 instance 1 40288 instance 2 40304 instance 3 40320 instance 4 40336 instance 5 40352 instance 6 40368 instance 7 40384 instance 8 40400 ... instance 99 41856 ------------------------------------------- instance 0 41856 instance 1 41872 instance 2 41872 instance 3 41872 instance 4 41872 instance 5 41872 instance 6 41872