|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull Requests
Pull requests: 
 HistoryAllCommentsChangesGit/SVN commits              [2015-06-03 12:43 UTC] phofstetter at sensational dot ch
  [2015-06-03 13:05 UTC] phofstetter at sensational dot ch
  [2015-06-05 07:02 UTC] phofstetter at sensational dot ch
  [2015-06-10 15:48 UTC] ab@php.net
 
-Status:      Open
+Status:      Closed
-Assigned To:
+Assigned To: ab
  [2015-06-10 15:48 UTC] ab@php.net
 | |||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 03:00:01 2025 UTC | 
Description: ------------ using PDO PGSql, when calling closeCursor() on a statement before re-using it in a future execute(), some amount of memory is leaked every time the statement is executed. This only happens on DML statements (insert or update) and it only happens when closeCursor() is being called. Test script: --------------- <?php printf("I'm pid %d\n", getmypid()); $pdo = new PDO('pgsql:dbname=somedb;user=someuser;host=127.0.0.1'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $pdo->exec('discard all'); $pdo->exec("set client_encoding to 'utf-8'"); $pdo->beginTransaction(); $pdo->exec(" create table foo ( id bigserial not null primary key, field1 text not null, field2 text not null, field3 text not null, field4 int4 not null ) "); // leaks $stmt = $pdo->prepare("insert into foo (field1, field2, field3, field4) values (:field1, :field2, :field3, :field4)"); // also leaks //$stmt = $pdo->prepare("update foo set field1 = :field1, field2 = :field2, field3 = :field3 where field4 = :field4"); // doesn't leak //$stmt = $pdo->prepare("select * from foo where field1 = :field1 and field2 = :field2 and field3 = :field3 and field4 = :field4"); $max = 10000; for($i = 0; $i < $max; $i++) { $data = array( 'field1' => "field1: $i", 'field2' => "field2: $i", 'field3' => "field3: $i", 'field4' => $i ); $stmt->execute($data); $stmt->closeCursor(); // leak goes away if closeCursor() is removed printf("\r%d", memory_get_usage(true)/1024); } $pdo->rollBack(); Expected result: ---------------- printed memory usage should stay constant. Actual result: -------------- printed memory usage is continuously increasing.