Memory Leak in Zend_Db_Table?

8 messages Options
Embed this post
Permalink
Daniel Freudenberger-2

Memory Leak in Zend_Db_Table?

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Hello,

 

I wrote a cli script that updates about 23.000 records once a day. But after several thousand records have been updated, the script used more than 128mb of memory. I’m not quiet sure if it’s a zend_db_table or php related issue.

 

I wrote a little test-script to reproduce the memory leak. I’m running zf 1.0.2 and php 5.2.3 (cli / win32).

 

<?php

  protected function indexAction ()

  {

    $playcom = new PlaycomItems(); // just one table that extends Zend_Db_Table and sets the required $_name property

    $limit = 10;

     

    for($offset = 0; $offset < 10000; $offset += $limit) {

      $rows = $playcom->fetchAll(null, 'id ASC', $limit, $offset);

      echo memory_get_usage(true) . ' / ' . memory_get_usage(false) . " bytes in use.\n";

      unset($rows); // should not be necessary, but makes no difference anyway

    }

  }

?>

 

The output looks like this:

4456448 / 4371232 bytes in use.

4456448 / 4374144 bytes in use.

4456448 / 4376784 bytes in use.

4456448 / 4378840 bytes in use.

4456448 / 4381504 bytes in use.

4718592 / 4384176 bytes in use.

4718592 / 4386832 bytes in use.

4718592 / 4389392 bytes in use.

4718592 / 4391976 bytes in use.

4718592 / 4394632 bytes in use.

4718592 / 4397192 bytes in use.

4718592 / 4399736 bytes in use.

4718592 / 4402408 bytes in use.

......

 

 

Any help is appreciated,

Daniel

Nghia Doan

Re: Memory Leak in Zend_Db_Table?

Reply Threaded More More options
Print post
Permalink
Hi All,
I have the same proplem.
who can help me ?

Thanks
Nghia Doan

Daniel Freudenberger-2 wrote:
Hello,

 

I wrote a cli script that updates about 23.000 records once a day. But after
several thousand records have been updated, the script used more than 128mb
of memory. I'm not quiet sure if it's a zend_db_table or php related issue.

 

I wrote a little test-script to reproduce the memory leak. I'm running zf
1.0.2 and php 5.2.3 (cli / win32).

 

<?php

  protected function indexAction ()

  {

    $playcom = new PlaycomItems(); // just one table that extends
Zend_Db_Table and sets the required $_name property

    $limit = 10;

     

    for($offset = 0; $offset < 10000; $offset += $limit) {

      $rows = $playcom->fetchAll(null, 'id ASC', $limit, $offset);

      echo memory_get_usage(true) . ' / ' . memory_get_usage(false) . "
bytes in use.\n";

      unset($rows); // should not be necessary, but makes no difference
anyway

    }

  }

?>

 

The output looks like this:

4456448 / 4371232 bytes in use.

4456448 / 4374144 bytes in use.

4456448 / 4376784 bytes in use.

4456448 / 4378840 bytes in use.

4456448 / 4381504 bytes in use.

4718592 / 4384176 bytes in use.

4718592 / 4386832 bytes in use.

4718592 / 4389392 bytes in use.

4718592 / 4391976 bytes in use.

4718592 / 4394632 bytes in use.

4718592 / 4397192 bytes in use.

4718592 / 4399736 bytes in use.

4718592 / 4402408 bytes in use.

......

 

 

Any help is appreciated,

Daniel
StephaneF

Re: Memory Leak in Zend_Db_Table?

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Hi Daniel,

You should first try to update your ZF to the latest version 1.9.*.

I am pretty sure that your memory leak will disappear.


Warm Regards,
Stephane Fillon
On 23/10/2009, at 4:38 PM, Nghia Doan wrote:


Hi All,
I have the same proplem.
who can help me ?

Thanks
Nghia Doan


Daniel Freudenberger-2 wrote:

Hello,



I wrote a cli script that updates about 23.000 records once a day. But
after
several thousand records have been updated, the script used more than
128mb
of memory. I'm not quiet sure if it's a zend_db_table or php related
issue.



I wrote a little test-script to reproduce the memory leak. I'm running zf
1.0.2 and php 5.2.3 (cli / win32).



<?php

 protected function indexAction ()

 {

   $playcom = new PlaycomItems(); // just one table that extends
Zend_Db_Table and sets the required $_name property

   $limit = 10;



   for($offset = 0; $offset < 10000; $offset += $limit) {

     $rows = $playcom->fetchAll(null, 'id ASC', $limit, $offset);

     echo memory_get_usage(true) . ' / ' . memory_get_usage(false) . "
bytes in use.\n";

     unset($rows); // should not be necessary, but makes no difference
anyway

   }

 }

?>



The output looks like this:

4456448 / 4371232 bytes in use.

4456448 / 4374144 bytes in use.

4456448 / 4376784 bytes in use.

4456448 / 4378840 bytes in use.

4456448 / 4381504 bytes in use.

4718592 / 4384176 bytes in use.

4718592 / 4386832 bytes in use.

4718592 / 4389392 bytes in use.

4718592 / 4391976 bytes in use.

4718592 / 4394632 bytes in use.

4718592 / 4397192 bytes in use.

4718592 / 4399736 bytes in use.

4718592 / 4402408 bytes in use.

......





Any help is appreciated,

Daniel




--
View this message in context: http://www.nabble.com/Memory-Leak-in-Zend_Db_Table--tp13058095p26021546.html
Sent from the Zend DB mailing list archive at Nabble.com.


Mathieu Suen-3

Re: Memory Leak in Zend_Db_Table?

Reply Threaded More More options
Print post
Permalink
Can we know what was wrong in the previous version?

Stephane Fillon a écrit :

> Hi Daniel,
>
> You should first try to update your ZF to the latest version 1.9.*.
>
> I am pretty sure that your memory leak will disappear.
>
>
> Warm Regards,
> Stephane Fillon
> On 23/10/2009, at 4:38 PM, Nghia Doan wrote:
>
>>
>> Hi All,
>> I have the same proplem.
>> who can help me ?
>>
>> Thanks
>> Nghia Doan
>>
>>
>> Daniel Freudenberger-2 wrote:
>>>
>>> Hello,
>>>
>>>
>>>
>>> I wrote a cli script that updates about 23.000 records once a day. But
>>> after
>>> several thousand records have been updated, the script used more than
>>> 128mb
>>> of memory. I'm not quiet sure if it's a zend_db_table or php related
>>> issue.
>>>
>>>
>>>
>>> I wrote a little test-script to reproduce the memory leak. I'm running zf
>>> 1.0.2 and php 5.2.3 (cli / win32).
>>>
>>>
>>>
>


--
-- Mathieu Suen
--
Ralph Schindler-2

Re: Memory Leak in Zend_Db_Table?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Nghia Doan
Can you provide the ZF version you were using, the adapter, and version
of PHP?

-ralph

Nghia Doan wrote:

> Hi All,
> I have the same proplem.
> who can help me ?
>
> Thanks
> Nghia Doan
>
>
> Daniel Freudenberger-2 wrote:
>> Hello,
>>
>>  
>>
>> I wrote a cli script that updates about 23.000 records once a day. But
>> after
>> several thousand records have been updated, the script used more than
>> 128mb
>> of memory. I'm not quiet sure if it's a zend_db_table or php related
>> issue.
>>
>>  
>>
>> I wrote a little test-script to reproduce the memory leak. I'm running zf
>> 1.0.2 and php 5.2.3 (cli / win32).
>>
>>  
>>
>> <?php
>>
>>   protected function indexAction ()
>>
>>   {
>>
>>     $playcom = new PlaycomItems(); // just one table that extends
>> Zend_Db_Table and sets the required $_name property
>>
>>     $limit = 10;
>>
>>      
>>
>>     for($offset = 0; $offset < 10000; $offset += $limit) {
>>
>>       $rows = $playcom->fetchAll(null, 'id ASC', $limit, $offset);
>>
>>       echo memory_get_usage(true) . ' / ' . memory_get_usage(false) . "
>> bytes in use.\n";
>>
>>       unset($rows); // should not be necessary, but makes no difference
>> anyway
>>
>>     }
>>
>>   }
>>
>> ?>
>>
>>  
>>
>> The output looks like this:
>>
>> 4456448 / 4371232 bytes in use.
>>
>> 4456448 / 4374144 bytes in use.
>>
>> 4456448 / 4376784 bytes in use.
>>
>> 4456448 / 4378840 bytes in use.
>>
>> 4456448 / 4381504 bytes in use.
>>
>> 4718592 / 4384176 bytes in use.
>>
>> 4718592 / 4386832 bytes in use.
>>
>> 4718592 / 4389392 bytes in use.
>>
>> 4718592 / 4391976 bytes in use.
>>
>> 4718592 / 4394632 bytes in use.
>>
>> 4718592 / 4397192 bytes in use.
>>
>> 4718592 / 4399736 bytes in use.
>>
>> 4718592 / 4402408 bytes in use.
>>
>> ......
>>
>>  
>>
>>  
>>
>> Any help is appreciated,
>>
>> Daniel
>>
>>
>>
>
till

Re: Memory Leak in Zend_Db_Table?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Mathieu Suen-3
On Fri, Oct 23, 2009 at 10:17 AM, Mathieu Suen
<[hidden email]> wrote:
> Can we know what was wrong in the previous version?

You could also try:

svn diff \
--old=http://framework.zend.com/svn/framework/standard/tags/release-1.9.0/library/Zend/Db/Table.php
\
--new=http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Db/Table.php

This shows you the changes from 1.9.0 to trunk, in that file.

Till
Nghia Doan

Re: Memory Leak in Zend_Db_Table?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Ralph Schindler-2
Hi,
I use ZF ver 1.7.2, php 5.2.11.

Ralph Schindler-2 wrote:
Can you provide the ZF version you were using, the adapter, and version
of PHP?

-ralph

Nghia Doan wrote:
> Hi All,
> I have the same proplem.
> who can help me ?
>
> Thanks
> Nghia Doan
>
>
> Daniel Freudenberger-2 wrote:
>> Hello,
>>
>>  
>>
>> I wrote a cli script that updates about 23.000 records once a day. But
>> after
>> several thousand records have been updated, the script used more than
>> 128mb
>> of memory. I'm not quiet sure if it's a zend_db_table or php related
>> issue.
>>
>>  
>>
>> I wrote a little test-script to reproduce the memory leak. I'm running zf
>> 1.0.2 and php 5.2.3 (cli / win32).
>>
>>  
>>
>> <?php
>>
>>   protected function indexAction ()
>>
>>   {
>>
>>     $playcom = new PlaycomItems(); // just one table that extends
>> Zend_Db_Table and sets the required $_name property
>>
>>     $limit = 10;
>>
>>      
>>
>>     for($offset = 0; $offset < 10000; $offset += $limit) {
>>
>>       $rows = $playcom->fetchAll(null, 'id ASC', $limit, $offset);
>>
>>       echo memory_get_usage(true) . ' / ' . memory_get_usage(false) . "
>> bytes in use.\n";
>>
>>       unset($rows); // should not be necessary, but makes no difference
>> anyway
>>
>>     }
>>
>>   }
>>
>> ?>
>>
>>  
>>
>> The output looks like this:
>>
>> 4456448 / 4371232 bytes in use.
>>
>> 4456448 / 4374144 bytes in use.
>>
>> 4456448 / 4376784 bytes in use.
>>
>> 4456448 / 4378840 bytes in use.
>>
>> 4456448 / 4381504 bytes in use.
>>
>> 4718592 / 4384176 bytes in use.
>>
>> 4718592 / 4386832 bytes in use.
>>
>> 4718592 / 4389392 bytes in use.
>>
>> 4718592 / 4391976 bytes in use.
>>
>> 4718592 / 4394632 bytes in use.
>>
>> 4718592 / 4397192 bytes in use.
>>
>> 4718592 / 4399736 bytes in use.
>>
>> 4718592 / 4402408 bytes in use.
>>
>> ......
>>
>>  
>>
>>  
>>
>> Any help is appreciated,
>>
>> Daniel
>>
>>
>>
>
Ralph Schindler-2

Re: Memory Leak in Zend_Db_Table?

Reply Threaded More More options
Print post
Permalink
Do you know if this is specific to a particular DB adapter? Mysqli,
Pdo_Mysql, or perhaps Pdo_Pgsql?

-ralph

Nghia Doan wrote:

> Hi,
> I use ZF ver 1.7.2, php 5.2.11.
>
>
> Ralph Schindler-2 wrote:
>> Can you provide the ZF version you were using, the adapter, and version
>> of PHP?
>>
>> -ralph
>>
>> Nghia Doan wrote:
>>> Hi All,
>>> I have the same proplem.
>>> who can help me ?
>>>
>>> Thanks
>>> Nghia Doan
>>>
>>>
>>> Daniel Freudenberger-2 wrote:
>>>> Hello,
>>>>
>>>>  
>>>>
>>>> I wrote a cli script that updates about 23.000 records once a day. But
>>>> after
>>>> several thousand records have been updated, the script used more than
>>>> 128mb
>>>> of memory. I'm not quiet sure if it's a zend_db_table or php related
>>>> issue.
>>>>
>>>>  
>>>>
>>>> I wrote a little test-script to reproduce the memory leak. I'm running
>>>> zf
>>>> 1.0.2 and php 5.2.3 (cli / win32).
>>>>
>>>>  
>>>>
>>>> <?php
>>>>
>>>>   protected function indexAction ()
>>>>
>>>>   {
>>>>
>>>>     $playcom = new PlaycomItems(); // just one table that extends
>>>> Zend_Db_Table and sets the required $_name property
>>>>
>>>>     $limit = 10;
>>>>
>>>>      
>>>>
>>>>     for($offset = 0; $offset < 10000; $offset += $limit) {
>>>>
>>>>       $rows = $playcom->fetchAll(null, 'id ASC', $limit, $offset);
>>>>
>>>>       echo memory_get_usage(true) . ' / ' . memory_get_usage(false) . "
>>>> bytes in use.\n";
>>>>
>>>>       unset($rows); // should not be necessary, but makes no difference
>>>> anyway
>>>>
>>>>     }
>>>>
>>>>   }
>>>>
>>>> ?>
>>>>
>>>>  
>>>>
>>>> The output looks like this:
>>>>
>>>> 4456448 / 4371232 bytes in use.
>>>>
>>>> 4456448 / 4374144 bytes in use.
>>>>
>>>> 4456448 / 4376784 bytes in use.
>>>>
>>>> 4456448 / 4378840 bytes in use.
>>>>
>>>> 4456448 / 4381504 bytes in use.
>>>>
>>>> 4718592 / 4384176 bytes in use.
>>>>
>>>> 4718592 / 4386832 bytes in use.
>>>>
>>>> 4718592 / 4389392 bytes in use.
>>>>
>>>> 4718592 / 4391976 bytes in use.
>>>>
>>>> 4718592 / 4394632 bytes in use.
>>>>
>>>> 4718592 / 4397192 bytes in use.
>>>>
>>>> 4718592 / 4399736 bytes in use.
>>>>
>>>> 4718592 / 4402408 bytes in use.
>>>>
>>>> ......
>>>>
>>>>  
>>>>
>>>>  
>>>>
>>>> Any help is appreciated,
>>>>
>>>> Daniel
>>>>
>>>>
>>>>
>>
>