#41911 [Bgs]: Passing string encapsulated in SimpleXMLElement to strtotime causes memory leak

2007-07-06 Thread irb at redwoodtech dot com
 ID:   41911
 User updated by:  irb at redwoodtech dot com
 Reported By:  irb at redwoodtech dot com
 Status:   Bogus
 Bug Type: Date/time related
 Operating System: Windows XP SP2
 PHP Version:  5.2.3
 New Comment:

Tony, thanks for the quick response.

The messages being logged are generated by my own debug code (See the
echo statements in the reproduce code). Unless I've misunderstood your
comment, you've mistaken my debug messages for the memory leak alerts
raised by the engine.

I didn't mean for the issue raised to be the way in which the memory
leak is reported but rather the memory leak itself.

I asked someone on irc.freenode.net#php to double check my reasoning
and they told me that this looks bogus but for a different reason - that
PHP isn't designed for long-term processes. Is that right?

Any clarification you could provide would be very much appreciated.


Previous Comments:


[2007-07-06 09:20:22] [EMAIL PROTECTED]

All memory leaks are reported by the engine, this is the way the engine
works and it is perfectly acceptable.



[2007-07-06 06:06:02] irb at redwoodtech dot com

Description:

If a time string is to be read from a SimpleXML object and converted
into a unix timestamp then a memory leak occurs if the SimpleXML object
is passed directly to strtotime.

The memory leak can be stopped by type casting before passing the
string to strtotime. For example, change the relevant line in the
reproduce code to:

$lTime = strtotime ((string) $xml['timestamp']);

Reproduce code:
---
while(true)
{
$xml = new SimpleXMLElement('');
echo 'Current Daemon Memory Usage is ' . memory_get_usage ( ) ." bytes
: Before STRTOTIME\n";
$lTime = strtotime ($xml['timestamp']);
echo 'Current Daemon Memory Usage is ' . memory_get_usage ( ) ." bytes
: After STRTOTIME\n";
}

Expected result:

The following is expected. The point being that the memory usage of the
application is constant.

Current Daemon Memory Usage is 53720 bytes : Before STRTOTIME
Current Daemon Memory Usage is 53720 bytes : After STRTOTIME
Current Daemon Memory Usage is 53720 bytes : Before STRTOTIME
Current Daemon Memory Usage is 53720 bytes : After STRTOTIME
Current Daemon Memory Usage is 53720 bytes : Before STRTOTIME
Current Daemon Memory Usage is 53720 bytes : After STRTOTIME

Actual result:
--
Memory usage increases over time.

Current Daemon Memory Usage is ___94240 bytes : After STRTOTIME
Current Daemon Memory Usage is ___94400 bytes : Before STRTOTIME
Current Daemon Memory Usage is ___94440 bytes : After STRTOTIME
Current Daemon Memory Usage is ___94600 bytes : Before STRTOTIME
Current Daemon Memory Usage is ___94640 bytes : After STRTOTIME
Current Daemon Memory Usage is ___94800 bytes : Before STRTOTIME
Current Daemon Memory Usage is ___94840 bytes : After STRTOTIME





-- 
Edit this bug report at http://bugs.php.net/?id=41911&edit=1


#41911 [NEW]: Passing string encapsulated in SimpleXMLElement to strtotime causes memory leak

2007-07-05 Thread irb at redwoodtech dot com
From: irb at redwoodtech dot com
Operating system: Windows XP SP2
PHP version:  5.2.3
PHP Bug Type: Date/time related
Bug description:  Passing string encapsulated in SimpleXMLElement to strtotime 
causes memory leak

Description:

If a time string is to be read from a SimpleXML object and converted into
a unix timestamp then a memory leak occurs if the SimpleXML object is
passed directly to strtotime.

The memory leak can be stopped by type casting before passing the string
to strtotime. For example, change the relevant line in the reproduce code
to:

$lTime = strtotime ((string) $xml['timestamp']);

Reproduce code:
---
while(true)
{
$xml = new SimpleXMLElement('');
echo 'Current Daemon Memory Usage is ' . memory_get_usage ( ) ." bytes :
Before STRTOTIME\n";
$lTime = strtotime ($xml['timestamp']);
echo 'Current Daemon Memory Usage is ' . memory_get_usage ( ) ." bytes :
After STRTOTIME\n";
}

Expected result:

The following is expected. The point being that the memory usage of the
application is constant.

Current Daemon Memory Usage is 53720 bytes : Before STRTOTIME
Current Daemon Memory Usage is 53720 bytes : After STRTOTIME
Current Daemon Memory Usage is 53720 bytes : Before STRTOTIME
Current Daemon Memory Usage is 53720 bytes : After STRTOTIME
Current Daemon Memory Usage is 53720 bytes : Before STRTOTIME
Current Daemon Memory Usage is 53720 bytes : After STRTOTIME

Actual result:
--
Memory usage increases over time.

Current Daemon Memory Usage is ___94240 bytes : After STRTOTIME
Current Daemon Memory Usage is ___94400 bytes : Before STRTOTIME
Current Daemon Memory Usage is ___94440 bytes : After STRTOTIME
Current Daemon Memory Usage is ___94600 bytes : Before STRTOTIME
Current Daemon Memory Usage is ___94640 bytes : After STRTOTIME
Current Daemon Memory Usage is ___94800 bytes : Before STRTOTIME
Current Daemon Memory Usage is ___94840 bytes : After STRTOTIME

-- 
Edit bug report at http://bugs.php.net/?id=41911&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41911&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41911&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41911&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41911&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=41911&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=41911&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=41911&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=41911&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=41911&r=support
Expected behavior:http://bugs.php.net/fix.php?id=41911&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=41911&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=41911&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41911&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41911&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41911&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=41911&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=41911&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41911&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=41911&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=41911&r=mysqlcfg