php.net |  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
Votes:1
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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: anders at freeones dot com
New email:
PHP Version: OS:

 

 [2008-10-21 08:15 UTC] anders at freeones dot com
Description:
------------
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().',' 
                   .$this->getCountry().','.$this->getLocation().','.$this->getRaws().','.$this->getUniques().');';

#         $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();
         $lStatement->free();
       }


Expected result:
----------------
See code comments

Actual result:
--------------
see code comments

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-26 11:12 UTC] jani@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 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] andrey@php.net
-Package: MySQL related +Package: Scripting Engine problem
 [2010-08-18 12:31 UTC] andrey@php.net
not a mysql thing, still no feedback
 [2010-11-02 17:33 UTC] felipe@php.net
-Status: No Feedback +Status: Feedback
 [2010-11-02 17:33 UTC] felipe@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 11 17:01:27 2024 UTC