|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21806 sybase_unbuffered_query eats memory
Submitted: 2003-01-21 14:58 UTC Modified: 2003-03-27 07:07 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mayc at imsweb dot com Assigned:
Status: Closed Package: Sybase-ct (ctlib) related
PHP Version: 4.3.0 OS: Solaris 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mayc at imsweb dot com
New email:
PHP Version: OS:


 [2003-01-21 14:58 UTC] mayc at imsweb dot com
Large selection sets using sybase_query use too much memory, since it pulls the entire result set into memory.  In my example, the memory of the httpd daemon quickly builds to about 155MB before the 30 second timeout.  I had figured that sybase_unbuffered_query would solved that problem.  Unfortunately, it also bleeds memory, however not as bad.  It raises the memory usage of the httpd daemon to 53MB before the 30 second timeout.

I believe this is either a memory leak, or unbuffered query is actually still buffering something.

Below is a simplified example that shows the memory leak.  I am using Solaris 7, Sybase 11.9.2, and PHP 4.3.0.




$con = sybase_connect('peach5026d', 'may', '********');
sybase_select_db('db_dev', $con);

$fp = fopen('test.csv', "w");   // open the output file

$query = sybase_unbuffered_query("SELECT * FROM vial v WHERE v.study_id = 'ACC'", $con);

$max = sybase_num_fields($query);
while($row = sybase_fetch_row($query)) {
    $elements = array();
    for ($j = 0; $j < $max; $j++)
        $elements[] = $row[$j];
    fwrite($fp, implode(',', $elements) . "\r\n");
fclose($fp);   // close the file



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-25 17:32 UTC]
Use the parameter store_result of sybase_unbuffered_query to 
prevent it from "eating" memory.

sybase_unbuffered_query(string query [, int link_identifier [, bool store_result]])

From documentation (which is not online yet):
  The optional <parameter>store_result</parameter> can be FALSE to indicate
  the resultsets should'nt be fetched into memory, thus minimizing memory usage
  which is particularily interesting with very large resultsets.

 [2003-03-27 07:07 UTC]
docs are updated.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 03:01:29 2024 UTC