From:             anders at freeones dot com
Operating system: Linux 2.6.20-1.2320
PHP version:      5.2.6
PHP Bug Type:     MySQL related
Bug description:  string cocatination leaking memeory when using execute

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

-- 
Edit bug report at http://bugs.php.net/?id=46353&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=46353&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=46353&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=46353&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=46353&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=46353&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=46353&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=46353&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=46353&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=46353&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=46353&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=46353&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=46353&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=46353&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=46353&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=46353&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=46353&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=46353&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=46353&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=46353&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=46353&r=mysqlcfg

Reply via email to