php.net |  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
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: 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 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: 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.

Chuck

---------------------------

sybase_min_server_severity(11);

$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");
}
@sybase_free_result($query);
           
fclose($fp);   // close the file

@sybase_close($con);                                                            

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-25 17:32 UTC] thekid@php.net
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] sniper@php.net
docs are updated.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 22:01:28 2024 UTC