php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9407 Memory Problem while using self referencing objects...
Submitted: 2001-02-22 12:09 UTC Modified: 2002-08-28 13:52 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: zimt@php.net Assigned:
Status: Wont fix Package: Performance problem
PHP Version: 4.0.4pl1 OS: Linux (Red Hat 6.1german) on Ker
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2001-02-22 12:09 UTC] zimt@php.net
-----configure-----
"./configure" \
"--with-apache=../apache_1.3.14" \
"--with-mysql" \
"--enable-sysvshm" \
"--enable-sysvsem" \
"--with-gd" \
"--enable-trans-sid" \
"--with-config-file-path=/etc/" \
"--enable-url-includes" \
"--enable-magic-quotes" \
"--enable-track-vars" \
"--enable-sockets" \
"--with-jpeg-dir=/root/jpeg-6b/" \
"--with-imap=/root/imap-2000b" \
-----configure-----

maybe i should mention, that
this problem happend with every other configuration i tested (other Servers) too


-----sample-scripts-----
-----class-one-----
<?php
/**
* Class one
*/
class one 
{
 /**
 * @var object foobar contains reference to this object  
 */ 
 var $foobar1;
 
 /**
 * @var object foobar2 contains reference to another object  
 */ 
 var $foobar2;
 
 /**
 * Constructor, putting reference of array including this object in class var $foobar 
 * @param object foobar reference to array including this object
 */
 function one(&$foobar)
 {
  $this->foobar1 =& $foobar[0];
  $this->foobar2 =& $foobar[1];
 }
}
?>
-----class-one-----
-----class-two-----
<?php
/**
* Class one
*/
class two extends some_other_class_but_not_class_one 
{
 /**
 * @var string foo defaults to "bar"  
 */ 
 var $foo ="bar";
 
 /**
 * Calling constructor of parent class.. nothing from intrest,
 * tested this using diffrent classes, this example is just
 * meant for those who say "Why dont you just extend class 
 * one/two to let them work together  
 */
 function two()
 {
   $this->some_other_class_but_not_class_one();  
 }
}
?>
-----class-two-----
-----script------

<?php
include("class.one.php");
include("class.two.php");

/* needed for some reasons, i dont think here is the problem */
session_start();
session_register($classarray);

$classarray[0] = new one($classarray);
$classarray[1] = new two;
?>
-----script------
-----sample-scripts-----

-----problem-----
Execute a set of scripts like this, uhm say 3000 times, youll notice that 
your free mem will get lower and lower...
i noticed that when my mem was full... not really cool...

i think this is a problem of the garbage collection, but im not sure...

any ideas?


Peter Petermann

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-09 13:47 UTC] andre@php.net
cicrular/self references are known to leak memory, not sure
if this can be improved
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Dec 04 08:03:38 2021 UTC