Re: Memory leak with .=

From: Date: Tue, 02 Mar 2004 10:13:49 +0000
Subject: Re: Memory leak with .=
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-8298@lists.php.net to get a copy of this message
Fixed. Thanks for the reproducing case. At 11:25 PM 2/27/2004 +0100, Timm Friebe wrote:
The following script: <?php class StringBuffer {
    public $buf= '';
    public function append($string) {
      $this->buf.= ($string instanceof StringBuffer
        ? $string->buf
        : $string
      );
    }
} $s= new StringBuffer(); $s->append('Hello'); ?> causes: /usr/home/thekid/devel/php/php/Zend/zend_execute.c(4049) : Freeing 0x083B0310 (6 bytes), script=string.php /usr/home/thekid/devel/php/php/Zend/zend_variables.c(137) : Actual location (location was relayed) === Total 1 memory leaks detected === Changing the line $this->buf.= [...] to $this->buf= $this->buf. makes the leak disappear. - Timm -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#8298) next »