|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46353 string concatenation leaks memory when using execute
Submitted: 2008-10-21 08:15 UTC Modified: 2013-02-18 00:33 UTC
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: anders at freeones dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.2.6 OS: Linux 2.6.20-1.2320
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
43 + 36 = ?
Subscribe to this entry?

 [2008-10-21 08:15 UTC] anders at freeones dot com
I run some code 5 million itteration yesterday, today I change my string building to use single quotes and the dot operator. That version was able to do aprox 25k itterations then the script died due memory leak.

Reproduce code:
#           Makign a string like this leaks NOT memory

#         $lInsert = "Insert into {$this->mTable} (datetime,entity_id,entity_type,domain,country,location,raws,uniques)" .
#                    " values ('{$this->getDateTime()}',{$this->getEntityId()},{$this->getEntityType()},{$this->getDomain()}," .
#                    "{$this->getCountry()},{$this->getLocation()},{$this->getRaws()},{$this->getUniques()});";

#           Making a string liek this leaks memory when doign execute
         $lInsert = 'Insert into '.$this->mTable.' (datetime,entity_id,entity_type,domain,country,location,raws,uniques)' .
                   ' values ("'.$this->getDateTime().'",'.$this->getEntityId().','.$this->getEntityType().','.$this->getDomain().',' 

#         $lInsert = "Insert into {$this->mTable} (datetime,entity_id,entity_type,domain,country,location,raws,uniques)" .
#                   " values ('{$lTimeStamp}',{$lEntityId},{$lEntityType},{$lDomain},{$lCountry},{$lLocation},{$lRaws},{$lUniques})";
      print memory_get_usage()."\n";
      $lStatement =& $this->mDbh->prepare($lInsert);
      if (MDB2::isError($lStatement)){
           error_log($lStatement->getMessage().';query:'.$lInsert.' '.$lStatement->userinfo);
         $lResult = false;
       } else {
         $lResult =& $lStatement->execute();

Expected result:
See code comments

Actual result:
see code comments


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-26 11:12 UTC]
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 the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

 [2008-11-03 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".
 [2010-08-18 12:31 UTC]
-Package: MySQL related +Package: Scripting Engine problem
 [2010-08-18 12:31 UTC]
not a mysql thing, still no feedback
 [2010-11-02 17:33 UTC]
-Status: No Feedback +Status: Feedback
 [2010-11-02 17:33 UTC]
Please try using this snapshot:
For Windows:

 [2013-02-18 00:33 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Dec 03 12:03:44 2022 UTC