narendrasuthar / php-reader

Automatically exported from code.google.com/p/php-reader
0 stars 0 forks source link

Memory leak in ISO14496 #17

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I was very glad to find this php-reader library, as I needed to get meta
data from m4a files.  It works well except when I try to read many files
because I am experiencing a memory leak. 

I've attached code that reads the same file multiple times and displays
memory usage after each call.  When I run it I see the memory growing, eg

1: Balgeddie Reel R5x32 577456
2: Balgeddie Reel R5x32 625456
3: Balgeddie Reel R5x32 672944
4: Balgeddie Reel R5x32 720408
5: Balgeddie Reel R5x32 767736
....

Is there something I need to do to free up the memory?

Patty

Original issue reported on code.google.com by Patty.Li...@gmail.com on 24 Apr 2009 at 6:03

Attachments:

GoogleCodeExporter commented 8 years ago
It seems like the problem is caused by circular references and is thus more of a
problem of PHP rather than the library code. It seems to be a known weakness of
reference counting schemes: http://bugs.php.net/bug.php?id=33595.

This can also be verified by commenting line 280 of Box.php that sets the parent
reference to all the child boxes. The memory stays constant having that line 
commented.

I will keep the issue open until I come up with something for this. Thanks for 
reporting!

Original comment by svollbehr on 26 Apr 2009 at 5:10

GoogleCodeExporter commented 8 years ago
The following code reproduces the problem:

{{{
class A {
    private $parent = null;
    private $childs = array();
    public function setParent(&$parent) {
        $this->parent = $parent;
    }
    public function addChild($child) {
        $this->childs[] = $child;
    }
}

for ($i = 1; $i <= 16; $i++) {
    $a = new A();
    for ($j = 1; $j <= 16; $j++) {
        $b = new A();
        $b->setParent($a);
        $a->addChild($b);
    }
    echo "$i: " . memory_get_usage()."\n";
}
}}}

Let me know if you (or anyone for that matter) come up with a solution to that. 
Even
5.3.0RC1 leaks memory with this code.

Original comment by svollbehr on 26 Apr 2009 at 5:32

GoogleCodeExporter commented 8 years ago

Original comment by svollbehr on 30 Apr 2011 at 8:12