[PHP-BUG] Bug #65300 [NEW]: Memory leak when initializing objects

2013-07-20 Thread zlobnygrif at gmail dot com
From: zlobnygrif at gmail dot com
Operating system: debian/ubuntu
PHP version:  5.4.17
Package:  *General Issues
Bug Type: Bug
Bug description:Memory leak when initializing objects

Description:

If I set object property run-time it uses more memory than equal default
property value.

Test script:
---
printf(PHP %s %s\n\n, PHP_VERSION, PHP_OS);

class Order {
public $id = '123';
public $number = '1234';
public $date   = '12345';
}

$orders = [];

printf(Test1\nMem before: %.2f mb\n, memory_get_usage(true) / 1024 /
1024);
for ( $i = 0; ++$i  10; )
{
$order = new Order;
$orders[] = $order;
}
printf(Mem after: %.2f mb\n\n, memory_get_usage(true) / 1024 / 1024);

unset($orders, $i);
$orders = [];

printf(Test2\nMem before: %.2f mb\n, memory_get_usage(true) / 1024 /
1024);
for ( $i = 0; ++$i  10; )
{
$order = new Order;
$orders[] = $order;
}
printf(Mem after: %.2f mb\n\n, memory_get_usage(true) / 1024 / 1024);

unset($orders, $i);
$orders = [];

printf(Test3\nMem before: %.2f mb\n, memory_get_usage(true) / 1024 /
1024);
for ( $i = 0; ++$i  10; )
{
$order = new Order;

$order-id = '123';
$order-number = '12345';
$order-date   = '123456';

$orders[] = $order;
}
printf(Mem after: %.2f mb\n\n, memory_get_usage(true) / 1024 / 1024);

unset($orders, $i);

printf(Mem after: %.2f mb\n\n, memory_get_usage(true) / 1024 / 1024);

Expected result:

no memory leaks

Actual result:
--
PHP 5.4.17-1~dotdeb.0 Linux

Test1
Mem before: 0.25 mb
Mem after: 16.25 mb

Test2
Mem before: 4.75 mb
Mem after: 16.25 mb

Test3
Mem before: 5.00 mb
Mem after: 24.25 mb

Mem after: 5.25 mb



-- 
Edit bug report at https://bugs.php.net/bug.php?id=65300edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65300r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65300r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=65300r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=65300r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=65300r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65300r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=65300r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=65300r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=65300r=support
Expected behavior:  https://bugs.php.net/fix.php?id=65300r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=65300r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=65300r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=65300r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65300r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=65300r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=65300r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=65300r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65300r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65300r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65300r=mysqlcfg



#49439 [NEW]: (unicode) and (string) types

2009-09-02 Thread zlobnygrif at gmail dot com
From: zlobnygrif at gmail dot com
Operating system: FreeBSD 7.2-RELEASE
PHP version:  6SVN-2009-09-02 (snap)
PHP Bug Type: Unicode Engine related
Bug description:  (unicode) and (string) types

Description:

ENG: Functions for working with strings return different types. Because of
this, for example, function strtr not working properly.

RUS: Ôóíêöèè äëÿ ðàáîòû ñî ñòðîêàìè âîçâðàùàþò ðàçíûå òèïû ðåñóðñîâ. Èç-çà
ýòîãî äðóãèå ôóíêöèè, íàïðèìåð strtr, ðàáîòàþò íåïðàâèëüíî.

Reproduce code:
---
$sour = 'hello';

ob_start();
echo $sour;
$buff = ob_get_clean();

var_dump($sour);
var_dump($buff);

var_dump($sour === $buff);
var_dump(substr($buff,0));

var_dump(strtr($buff, array($sour = 'HELLO')));
var_dump(strtr($buff, $sour, 'HELLO'));

Expected result:

unicode(5) hello
string(5) hello
bool(false)
string(5) hello
string(5) hello
unicode(5) HELLO

Actual result:
--
unicode(5) hello
unicode(5) hello
bool(true)
unicode(5) hello
unicode(5) HELLO
unicode(5) HELLO

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