From:             [EMAIL PROTECTED]
Operating system: Solaris 7
PHP version:      4.3.0
PHP Bug Type:     Sybase-ct (ctlib) related
Bug description:  sybase_unbuffered_query eats memory

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);                                                      
     
-- 
Edit bug report at http://bugs.php.net/?id=21806&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=21806&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=21806&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=21806&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=21806&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=21806&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=21806&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=21806&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=21806&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=21806&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=21806&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21806&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=21806&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=21806&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=21806&r=gnused

Reply via email to