Sorry to post this again but it's a little urgent. The preg_replace in my script allocates a little memory every time it is called and doesn't free it again untill the script ends.
I don't know if it is normal behaviour for preg_replace or if it is my reg. exp. that causes this. The problem is that I call preg_replace a little more than 30000 times and that causes quite a lot of memory to be allocated. Doesn't anybody know if this is a problem in preg_replace or is there a better maillist/forum for this kind of questions? Any answer will be appreciated :) Ulrik S. Kofod sagde: > > $replace = "/^(([a-z]+?[^a-z]+?){".($count)."})(".$typedmask.")(.*)/iS"; > $with = "$1<error-start sourcetext=".$corr['sourcetext']." id=".$corr['id']." > group=\"".$corr['grupper']."\" class=\"".$corr['ordklasse']."\" > corrected-from=\"".$corr['typed']."\" > corrected-to=\"".$corr['corrected']."\">$3<error-end > sourcetext=".$corr['sourcetext']." id=".$corr['id'].">$4"; > $text = preg_replace ($replace,$with,$text,1); > > > Above preg_replace works as expected, I have it inside a loop that processes 1000 > texts and replaces a total of 30000 words. > > The problem is that it accumulates memory up to 200MB, that isn't freed again until > the script completes? > > It runs for about 1 - 2 minutes and allocates more and more memory. > > If I comment out the preg_replace the memory usage looks normal, so I'm pretty sure > that is where the problem is? > > My question is basically, is it something in my reg. exp. that it totally nuts or is > it normal behaviour for preg_replace to allocate memory and not free it again until > the script ends? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php