php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48368 Memory leak in array & objects
Submitted: 2009-05-23 17:24 UTC Modified: 2009-05-23 17:26 UTC
From: busia at tiscali dot it Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.0RC2 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: busia at tiscali dot it
New email:
PHP Version: OS:

 

 [2009-05-23 17:24 UTC] busia at tiscali dot it
Description:
------------
When I unset an array containing object, the memory is not freed as expected. Too much memory is still used.

Reproduce code:
---------------
<?
ini_set('memory_limit','300M');
class a {
}

echo memory_get_usage()."\n";
$a=array();
for ($i=0; $i<=1000000; $i++) {
	$a[]= new a();
}
echo memory_get_usage()."\n";
unset($a);
echo memory_get_usage()."\n";
?>

Expected result:
----------------
325776
230042304
circa 325776

Actual result:
--------------
325776
230042304
33977912

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-23 17:26 UTC] jani@php.net
unset != free. The memory is freed once the process shuts down. Until 
that, it's available inside the process. This is not a leak.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC