php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47514 memory leak in PDO::prepare while using pdo_pgsql
Submitted: 2009-02-26 23:25 UTC Modified: 2009-05-21 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: lukasz at fsi dot pl Assigned: mbeccati (profile)
Status: No Feedback Package: PDO related
PHP Version: 5.2.9 OS: FreeBSD 6.4
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-02-26 23:25 UTC] lukasz at fsi dot pl
Description:
------------
Calling prepare() for pdo_pgsql connection consumes memory which is never being freed. Specified query doesn't matter. It seems that this happen because in my case pdo_pgsql does not use native prepared statements, but I can't find the reason for this. I think so because calling prepare("foo") does not cause an error as it does when I use pdo_mysql.

Reproduce code:
---------------
$a = new PDO('pgsql:'.$some_pdo_pgsql_dsn);
for ($i = 0; $i < 1000000; $i++)
{
    $st = $a->prepare("");
    print(memory_get_usage(true)."\n");
    unset($st);
}


Expected result:
----------------
constant memory usage

Actual result:
--------------
increasing memory usage

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-03 01:18 UTC] iliaa@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

memory usage does not appear to change is latest cvs
 [2009-03-04 18:49 UTC] lukasz at fsi dot pl
The problem this exists in 5.2.9. I think that for some reason in my case native prepared statements are not used.
 [2009-03-04 18:51 UTC] lukasz at fsi dot pl
I've tried to change bug status to open but I can't do this.
 [2009-05-12 22:49 UTC] mbeccati@php.net
I've tested on FreeBSD 6.2 and Linux with php 5.2/5.3 compiled with libpq from 7.4.0 and 8.3.7.

When 8.3 was used I also tried to forcibly disable server side prepared statements with:

$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);

Unfortunately, I couldn't replicate your issue.

Would you mind checking which version of libpq is used in the pdo_pgsql extension? You can get it via phpinfo(), i.e.

PDO Driver for PostgreSQL	enabled
PostgreSQL(libpq) Version 	7.4
 [2009-05-21 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: Mon May 13 22:01:31 2024 UTC