php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42565 Excessive memory allocation
Submitted: 2007-09-05 13:59 UTC Modified: 2007-09-06 11:08 UTC
From: devis at lucato dot it Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.2.4 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: devis at lucato dot it
New email:
PHP Version: OS:

 

 [2007-09-05 13:59 UTC] devis at lucato dot it
Description:
------------
I'm having memory usage problems as in Bug #41053 (http://bugs.php.net/bug.php?id=41053).

PHP allocates much more memory on 64 bit systems, probably using 64 bit variables to describe the array structure.

The following script uses 130Mb for 2Mb of data but in production systems the situation gets worse, working with big arrays and concurrent connections the wasted memory is much more... 

Is there any suggestion/trick/setting useful (apart code optimizaztion, rolling back to 32 bit hardware or doubling available ram) ? 
Any news in PHP development about memory optimization ? Perhaps some settings to disable or reduce the internal arrays structure ?

Reproduce code:
---------------
<?php
function getMemoryUsage()
{
	return round(memory_get_usage() / (1024*1024), 1)." MB";
}
function printMemoryUsage()
{
	print("Memory = ".getMemoryUsage()." <br>\n");
}
printMemoryUsage();

$end = 1000000;
$array = array();
printMemoryUsage();
for($i = 0; $i < $end; $i++)
{
	$array[$i] = 0;
}
printMemoryUsage();
?>

Expected result:
----------------
Well, I expect a better memory usage.

Actual result:
--------------
Running matthieu script (see below) on different systems I get this results:

32 BIT SERVER
-------------
PHP 5.2.4 result is 68.9 MB
PHP 4.4.4 result is 57.5 MB

64 BIT SERVER
-------------
PHP 5.2.4 result is 130.2 MB
PHP 4.4.4 result is 99.6 MB

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-06 11:08 UTC] jani@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC