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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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: Wed Apr 24 18:01:28 2024 UTC