|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-12-31 07:35 UTC] nikcomestotalk at gmail dot com
Description:
------------
Memory getting exhausted when a php script[staticarray.php] is included multiple times.
staticarray.php size is 221K and which contain only arrays
Example
memcheck.php[Code shown in test script]
When i simply execute this
02.75 mb
12.75 mb
22.75 mb
32.75 mb
42.75 mb
52.75 mb
62.75 mb
72.75 mb
82.75 mb
92.75 mb
102.75 mb
I have used include_once, still memory usage keeps getting up.
Steps i had taken to stop memory usage, but went in vain
1. use gc_enable
2. put unset(Variable name) above every array creation
Test script:
---------------
//Memcheck.php
<?php
for($i=0;$i<10;$i++)
{
include_once("staticarray.php");
echo "\n $i". convert(memory_get_usage(true));
}
$CITY_DROP=array();
echo "\n $i". convert(memory_get_usage(true));
function convert($size)
{
$unit=array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}
?>
Expected result:
----------------
I expect memory usage should be same throughout.
02.75 mb
02.75 mb
02.75 mb
02.75 mb
02.75 mb
02.75 mb
02.75 mb
02.75 mb
02.75 mb
02.75 mb
02.75 mb
Actual result:
--------------
02.75 mb
12.75 mb
22.75 mb
32.75 mb
42.75 mb
52.75 mb
62.75 mb
72.75 mb
82.75 mb
92.75 mb
102.75 mb
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 11:00:02 2026 UTC |
testscript has already been added Memcheck.php staticarray.php[Data is too huge, so adding few arrays to script][And i can't share the real data, some legal issues] <?php $siteType=array("API","MOBILE","WEB","ANDROIDAPP","IOSAPP"); $siteServer=array("127.0.0.1","127.0.0.2","127.0.0.3","127.0.0.4"); $country=array("INDIA","AUSTRALIA","UK","USA","CHINA","JAPAN"); ?>