php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34222 str_replace leaks when replacing text in arrays
Submitted: 2005-08-23 17:56 UTC Modified: 2005-08-31 01:00 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: phpbug at phormix dot com Assigned:
Status: No Feedback Package: Strings related
PHP Version: 4.4.0 OS: Debian Gnu/Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: phpbug at phormix dot com
New email:
PHP Version: OS:

 

 [2005-08-23 17:56 UTC] phpbug at phormix dot com
Description:
------------
Replacing items in an array of  20-30 items with str_replace seems to leak memory. The application in question would crash when parsing various larger CSV files, using upwards to >500MB  per an 18MB data-file. 

Jumps in memory usage were observed at the point where str_replace was run. Using the function 'preg_replace' instead issued no such leak

Reproduce code:
---------------
str_replace('~comma~', ',', $myarray );

Expected result:
----------------
(values of ~comma~ in string were replaced with actual commas)

Actual result:
--------------
Progress would end indicating in logs that the memory limit of 500MB (as indicated in php.ini) was exceeded.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-23 23:47 UTC] sniper@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.


 [2005-08-31 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 05:01:27 2024 UTC