php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27174 unset dose not free up memory when used on arrays
Submitted: 2004-02-06 23:56 UTC Modified: 2004-02-08 00:16 UTC
From: zor at smallinfinity dot com Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 4.3.4 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
10 + 9 = ?
Subscribe to this entry?

 
 [2004-02-06 23:56 UTC] zor at smallinfinity dot com
Description:
------------
php-cli is not freeing up memory of an array. I am haveing this problem on a large scale and is makeing php take up 40mbs+.

Iv tryed unsetting each value independly. It still had the same problem.
Also this same thing seems to be happening to foreach. 


Reproduce code:
---------------
<?
		$test_array = Array();
		$pid = getmypid();
		$loop = 2000;
		echo "Starting Memory:\n";
		echo "USAGE (% KB PID ): " .`ps -eo%mem,rss,pid | grep $pid` . "\n";
		for($i=0;$loop > $i;$i++){
			$test_array[] = str_repeat("test", 5000);
		}
		echo "Finished Loop:\n";
		echo "USAGE (% KB PID ): " .`ps -eo%mem,rss,pid | grep $pid` . "\n";
		unset($test_array);
		echo "Cleaned Up:\n";
		echo "USAGE (% KB PID ): " .`ps -eo%mem,rss,pid | grep $pid` . "\n";
?>

Expected result:
----------------
Starting Memory:
USAGE (% KB PID ):  0.1 3592 14473

Finished Loop:
USAGE (% KB PID ):  1.3 42880 14473

Cleaned Up:
USAGE (% KB PID ):  1.3 3592 14473


Actual result:
--------------
Starting Memory:
USAGE (% KB PID ):  0.1 3592 14473

Finished Loop:
USAGE (% KB PID ):  1.3 42880 14473

Cleaned Up:
USAGE (% KB PID ):  1.3 42880 14473


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-07 22:48 UTC] sniper@php.net
Expected behaviour.

 [2004-02-08 00:16 UTC] zor at smallinfinity dot com
If this expected behaviour, is there any way to actually free up memory, Im trying to build a socket server and its takeing up about 40-50mbs a day that cant be cleared without stoping and starting the server.

Ny avaliable resources are low without php seeing how much memory it can take holdng unset and old data.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 18:01:30 2024 UTC