Memory leak in Zend_Date?

View: New views
8 Messages — Rating Filter:   Alert me  

Memory leak in Zend_Date?

by fab2008 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I don't know if this is a bug, but in one of my controller I get this:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 1245184 bytes) in /Users/fabio/Zend/ZendFramework-1.5.2/library/Zend/Date.php on line 2539

At the line 2539 I found this instruction

$this->mktime($hour,     $minute,   $second,   1 + $month,  1 + $day,      1970 + $year,     true), false);

Now, what's sound strange to me is the allocation of more than one Megabyte for this instruction.

In my script I solved the problem setting the memory limit to 16M, but I remain perplexed.

Should I open an issue on ZF issue system?

Thanks.

Re: Memory leak in Zend_Date?

by thomasW :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Don't you think that just giving an error message is not enough to reproduce
anything ???

Which date have you tried ?
Which timezone ?
Do you use one date object or multiple ?
Do you use caching ?
Which locale is being used ?
Have you tried to use the date standalone for reproduction ?

Please do a little bit of simple debugging yourself. Otherwise it's almost
impossible to help you.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

----- Original Message -----
From: "fab2008" <f.napoleoni@...>
To: <fw-general@...>
Sent: Wednesday, July 09, 2008 2:21 AM
Subject: [fw-general] Memory leak in Zend_Date?


>
> Hi all,
>
> I don't know if this is a bug, but in one of my controller I get this:
>
> Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
> allocate 1245184 bytes) in
> /Users/fabio/Zend/ZendFramework-1.5.2/library/Zend/Date.php on line 2539
>
> At the line 2539 I found this instruction
>
> $this->mktime($hour,     $minute,   $second,   1 + $month,  1 + $day,
> 1970 + $year,     true), false);
>
> Now, what's sound strange to me is the allocation of more than one
> Megabyte
> for this instruction.
>
> In my script I solved the problem setting the memory limit to 16M, but I
> remain perplexed.
>
> Should I open an issue on ZF issue system?
>
> Thanks.
> --
> View this message in context:
> http://www.nabble.com/Memory-leak-in-Zend_Date--tp18351959p18351959.html
> Sent from the Zend Framework mailing list archive at Nabble.com.


Re: Memory leak in Zend_Date?

by fab2008 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

thomasW wrote:
Don't you think that just giving an error message is not enough to reproduce
anything ???
You're right, I gave you too few information, but I guess my problem is solved by setting memory limit to 16Mb.

I don't know very well ZF internals, neither php memory allocation techniques; I guess that the message "tried to allocate 1245184 bytes" in php correspond to a C malloc, so it sounds strange that a single Zend_Date object would malloc more than 1Mb of memory for a line such as the one I posted (line 2539).

What I want to say is that if there exists any problem it is in Zend_Date itself, not in my code, but perhaps I'm completely wrong.

Re: Memory leak in Zend_Date?

by Lars Strojny-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Am Samstag, den 12.07.2008, 05:49 -0700 schrieb fab2008:
> What I want to say is that if there exists any problem it is in
> Zend_Date itself, not in my code, but perhaps I'm completely wrong.

I guess not. When playing around with Zend_Date we found out the same
with the result that we dropped using Zend_Date at all which works as
DateTime in core becomes more mature.

cu, Lars


signature.asc (852 bytes) Download Attachment

Re: Memory leak in Zend_Date?

by Matthew Weier O'Phinney-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-- Lars Strojny <lars@...> wrote
(on Saturday, 12 July 2008, 10:22 PM +0200):
> Am Samstag, den 12.07.2008, 05:49 -0700 schrieb fab2008:
> > What I want to say is that if there exists any problem it is in
> > Zend_Date itself, not in my code, but perhaps I'm completely wrong.
>
> I guess not. When playing around with Zend_Date we found out the same
> with the result that we dropped using Zend_Date at all which works as
> DateTime in core becomes more mature.

Lars -- can you provide some benchmarks that show the memory differences
between Zend_Date and DateTime? I'm curious to see if we might be able
to isolate the performance issues, if any, and improve the situation.

--
Matthew Weier O'Phinney
Software Architect       | matthew@...
Zend Framework           | http://framework.zend.com/

Re: Memory leak in Zend_Date?

by Lars Strojny-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Matthew,

Am Samstag, den 12.07.2008, 19:11 -0400 schrieb Matthew Weier O'Phinney:
[...]
> Lars -- can you provide some benchmarks that show the memory differences
> between Zend_Date and DateTime? I'm curious to see if we might be able
> to isolate the performance issues, if any, and improve the situation.

You can find the results attached. The benchmark suite can be found at
http://lars.schokokeks.org/php/time-bench.phps

cu, Lars

Instanciating Zend_Date
   - Average memory usage: 55.440000
   - Overall memory usage: 55440.000000
   - Average time consumed (mS): 0.001242
   - Overall time consumed: (mS): 1.241695

Instanciating DateTime
   - Average memory usage: 0.272000
   - Overall memory usage: 272.000000
   - Average time consumed (mS): 0.000012
   - Overall time consumed: (mS): 0.011888

Returning a formatted date with DateTime
   - Average memory usage: 0.000000
   - Overall memory usage: 0.000000
   - Average time consumed (mS): 0.000005
   - Overall time consumed: (mS): 0.005046

Returning a formatting date with with Zend_Date
   - Average memory usage: 9.800000
   - Overall memory usage: 9800.000000
   - Average time consumed (mS): 0.000750
   - Overall time consumed: (mS): 0.750078

Parsing date with DateTime
   - Average memory usage: 0.000000
   - Overall memory usage: 0.000000
   - Average time consumed (mS): 0.000015
   - Overall time consumed: (mS): 0.014650

Parsing date with Zend_Date
   - Average memory usage: 67.696000
   - Overall memory usage: 67696.000000
   - Average time consumed (mS): 0.008197
   - Overall time consumed: (mS): 8.197300



signature.asc (852 bytes) Download Attachment

Re: Memory leak in Zend_Date?

by Bruno Friedmann-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Lars Strojny wrote:

> Hi Matthew,
>
> Am Samstag, den 12.07.2008, 19:11 -0400 schrieb Matthew Weier O'Phinney:
> [...]
>> Lars -- can you provide some benchmarks that show the memory differences
>> between Zend_Date and DateTime? I'm curious to see if we might be able
>> to isolate the performance issues, if any, and improve the situation.
>
> You can find the results attached. The benchmark suite can be found at
> http://lars.schokokeks.org/php/time-bench.phps
>
> cu, Lars
>
Here You will find some tests made with the Lars benchmark code.

I join also my phpinfo as I 've a quiet big number of large module (clamav,mapserver/phpmapscrip/pdflib)
Computer is a Dell Precision M4300 with the cpu running at 2.4Ghz (Core2Duo centrino) with 4GB ram and a 7200 rpms hdd.


Hope this help you to find some numbers.



--

     Bruno Friedmann

Ioda-Net Sàrl   - www.ioda-net.ch
  2830 Vellerat - Switzerland

  Tél : ++41 32 435 7171
  Fax : ++41 32 435 7172
  gsm : ++41 78 802 6760

C'est Facile et Cool d'Évoluer en ligne : www.cfcel.com


Instanciating Zend_Date
   - Average memory usage: 38.976000
   - Overall memory usage: 38976.000000
   - Average time consumed (mS): 0.000665
   - Overall time consumed: (mS): 0.664856

Instanciating DateTime
   - Average memory usage: 0.080000
   - Overall memory usage: 80.000000
   - Average time consumed (mS): 0.000005
   - Overall time consumed: (mS): 0.005224

Returning a formatted date with DateTime
   - Average memory usage: 0.000000
   - Overall memory usage: 0.000000
   - Average time consumed (mS): 0.000002
   - Overall time consumed: (mS): 0.001551

Returning a formatting date with with Zend_Date
   - Average memory usage: 6.704000
   - Overall memory usage: 6704.000000
   - Average time consumed (mS): 0.000314
   - Overall time consumed: (mS): 0.313712


phpinfo.txt.bz2 (13K) Download Attachment

Re: Memory leak in Zend_Date?

by ota mares :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Lars Strojny wrote:

> Hi Matthew,
>
> Am Samstag, den 12.07.2008, 19:11 -0400 schrieb Matthew Weier O'Phinney:
> [...]
>  
>> Lars -- can you provide some benchmarks that show the memory differences
>> between Zend_Date and DateTime? I'm curious to see if we might be able
>> to isolate the performance issues, if any, and improve the situation.
>>    
>
> You can find the results attached. The benchmark suite can be found at
> http://lars.schokokeks.org/php/time-bench.phps
>
> cu, Lars
>  
Before the topic gets forgotten, ill add myself to the benchmark list.

SuSe Linux 10.0
Intel(R) Pentium(R) 4 CPU 3.00GHz  
MemTotal: 1025604 kB

Instanciating Zend_Date

   - Average memory usage: 84.604000
   - Overall memory usage: 84604.000000
   - Average time consumed (mS): 0.001542
   - Overall time consumed: (mS): 1.542281

Instanciating DateTime
   - Average memory usage: -0.792000
   - Overall memory usage: -792.000000
   - Average time consumed (mS): 0.000016
   - Overall time consumed: (mS): 0.015954

Returning a formatted date with DateTime
   - Average memory usage: 0.224000
   - Overall memory usage: 224.000000
   - Average time consumed (mS): 0.000004
   - Overall time consumed: (mS): 0.003700

Returning a formatting date with with Zend_Date
   - Average memory usage: 0.060000
   - Overall memory usage: 60.000000
   - Average time consumed (mS): 0.000663
   - Overall time consumed: (mS): 0.663352