php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46180 memory leak on unset(array)
Submitted: 2008-09-26 10:13 UTC Modified: 2008-09-26 19:51 UTC
From: xl269 at cam dot ac dot uk Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.3CVS-2008-09-26 (CVS) OS: debian gnu/linux lenny
Private report: No CVE-ID: None
 [2008-09-26 10:13 UTC] xl269 at cam dot ac dot uk
Description:
------------
unset(array) doesn't free up all the memory. or perhaps setting elements in an array is using up memory that can't be freed. whatever, I dunno how Zend works.

basically, bug 41713 isn't actually fixed.

also it'd be helpful if someone explains why unset() seems to use up ~200B of memory regardless. in a CLI daemon that's a significant memory leak.


Reproduce code:
---------------
<?php
define('LF', chr(10));

$a = null;
echo memory_get_usage().LF;

$a = str_repeat("test", 65536);
echo memory_get_usage().LF;

unset($a);
echo memory_get_usage().LF;

for ($i=0; $i<65536; $i++) { $a[] = "test"; }
echo memory_get_usage().LF;

unset($a);
echo memory_get_usage().LF;

?>


Expected result:
----------------
627560
889944
627776
12163304
62xxxx


Actual result:
--------------
627560
889944
627776
12163304
888744



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-26 19:51 UTC] johannes@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

PHP doesn't free memory directly to the system but tries to reduce the number of system allocations therefore the memory usage doesn'T directly show "leaks."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 06:01:29 2024 UTC