php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27275 Array->String cast takes serious performance hit, leaks like crazy
Submitted: 2004-02-16 07:38 UTC Modified: 2004-03-15 10:12 UTC
From: john@php.net Assigned:
Status: Closed Package: Performance problem
PHP Version: 5CVS-2004-02-16 (4CVS) OS: *
Private report: No CVE-ID: None
 [2004-02-16 07:38 UTC] john@php.net
Description:
------------
It appears that the engine is doing a Copy-on-write when it shouldn't be because the variable is being cast to something else. If that is correct (that might not be the correct bug diagnosis), Not only does this slow everything down since you are doing deep copies when you don't need to be but it leaks like crazy.



Reproduce code:
---------------
<?php
        $a = array(1, 2, 3, 4, 5, 6);
        $b = $a;
        $b .= "foo";
?>



Expected result:
----------------
Nothing.


Actual result:
--------------
/home/john/working/php-src/Zend/zend_hash.c(756) :  Freeing 0x4045DCB8 (35 bytes), script=array.php
/home/john/working/php-src/Zend/zend_hash.c(377) : Actual location (location was relayed)
Last leak repeated 5 times
/home/john/working/php-src/Zend/zend_execute.c(1718) :  Freeing 0x4045DA70 (44 bytes), script=array.php
/home/john/working/php-src/Zend/zend_variables.c(148) : Actual location (location was relayed)
/home/john/working/php-src/Zend/zend_execute.c(3313) :  Freeing 0x4045D878 (16 bytes), script=array.php
Last leak repeated 5 times
/home/john/working/php-src/Zend/zend_variables.c(149) :  Freeing 0x4045E638 (32 bytes), script=array.php
/home/john/working/php-src/Zend/zend_hash.c(157) : Actual location (location was relayed)
=== Total 14 memory leaks detected ===

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-16 11:18 UTC] sniper@php.net
This happens with PHP 4 too, so it's nothing new..

 [2004-03-15 10:12 UTC] sniper@php.net
Apparently fixed in CVS now.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 05:01:29 2024 UTC