php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49345 Memory is not release
Submitted: 2009-08-24 13:50 UTC Modified: 2009-08-25 14:19 UTC
From: pearl1985 at interia dot pl Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.3.0 OS: Windows XP x64
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: pearl1985 at interia dot pl
New email:
PHP Version: OS:

 

 [2009-08-24 13:50 UTC] pearl1985 at interia dot pl
Description:
------------
When I was using function lambda in class, I saw that it is using a lot of operating memory. I saw this error when the script was sending e-mails reports to users registered in my service.

Reproduce code:
---------------
<?php
class example
{
	function test()
	{
		$var = create_function('', '$a = 1;$b=2;$c=$a+$b;');
		$var();
		unset($var);
	}
}
$example = new example;
for($i=0;$i<=10000;$i++)
{
	$example->test();
}

echo 'Results after remove lambda'."\n";
echo 'Memory limit: '.ini_get('memory_limit')."\n";
echo 'Usage: '. round(memory_get_usage()/1024/1024, 1)."\n";
echo 'Peak:'. round(memory_get_peak_usage()/1024/1024, 1);
echo "\n";

?>

Expected result:
----------------
I expected a slight growth of operating memory usage by script. By using endless loop, I expect the script will be executing even for 2 hours, thanks to correction of appropriate php configuration directive.

Actual result:
--------------
When I used endless loop while(true), php engine ended its work after 2 minutes,generating error "PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 40961 bytes)"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-24 14:28 UTC] jani@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

unset() does not free any memory.
 [2009-08-25 14:19 UTC] pearl1985 at interia dot pl
Ok, explain to me why, memory used by function create_function is not released after using function unset??
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 13:01:30 2024 UTC