From:             
Operating system: Linux
PHP version:      5.4.3
Package:          PDO related
Bug Type:         Bug
Bug description:GC not working, when used own row class

Description:
------------
When PDO is told to use my row class and pass PDOStatement into it, it
creates 
cyclic reference, that prevents GC from deleting the row data, when not
required 
anymore.

Test script:
---------------
$db = new PDO('mysql:host=127.0.0.1;dbname=information_schema', 'root',
'password');

class DbRow { public function __construct($stt = NULL) { } }
$begin = memory_get_usage();
for ($i=0; $i < 10 ;$i++) {
        $stt = $db->prepare("SELECT * FROM COLLATIONS");
        $stt->setFetchMode(PDO::FETCH_CLASS, 'DbRow');
        $stt->execute();
        $rows = $stt->fetchAll();

        echo number_format((memory_get_usage() - $begin) / 1000000, 2, '.', ' 
'),
" MB\n";
}

Expected result:
----------------
0.05 MB
0.05 MB
0.05 MB
0.05 MB
0.05 MB
0.05 MB
0.05 MB
0.05 MB
0.05 MB
0.05 MB

Actual result:
--------------
0.00 MB
0.05 MB
0.10 MB
0.14 MB
0.19 MB
0.24 MB
0.29 MB
0.34 MB
0.38 MB
0.43 MB

-- 
Edit bug report at https://bugs.php.net/bug.php?id=62111&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=62111&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=62111&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=62111&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=62111&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62111&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=62111&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=62111&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=62111&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=62111&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=62111&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=62111&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=62111&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=62111&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=62111&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=62111&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62111&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=62111&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=62111&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=62111&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=62111&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=62111&r=mysqlcfg

Reply via email to