php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21775 memory leak: emalloc(): Unable to alllocate 32 bytes
Submitted: 2003-01-20 10:30 UTC Modified: 2003-02-06 04:38 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: peter dot karl dot mueller at gmx dot de Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 4.3.0 OS: SuSE Linux 7.3
Private report: No CVE-ID: None
 [2003-01-20 10:30 UTC] peter dot karl dot mueller at gmx dot de
The following code:

<%
   class Object {
      var $prev;
      var $next;
      function unter (&$ref)
      {
         $ref->prev = &$this;
         $this->next = &$ref;
      }
   };

   while (true)
   {
      print "NEW ROUND\n";
      {
         $o = &new Object;
         for ($i = 0; $i < 10000; ++$i) {
            $o->unter (new Object);
            $o = &$o->next;
         }
         unset ($o);
      }
   }
%>

consumes as much memory it can get. I would expect that
PHP garbage-collects the memory.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-20 11:12 UTC] moriyoshi@php.net
PHP is designed to bail out (to stop executing) when the memory has been
run out. So it's natural that the runtime end up segfaulting.

 [2003-01-20 11:38 UTC] peter dot karl dot mueller at gmx dot de
PHP does not reclaim any memory no longer referenced?
No garbage collection?
 [2003-01-21 06:03 UTC] peter dot karl dot mueller at gmx dot de
my http process rund out of memory after it blowed up
to 320 MB (have 256 MB RAM). in php.ini memory_limit = 8M.
IMHO this is not bogus!
 [2003-01-21 07:26 UTC] moriyoshi@php.net
Sorry, my bad. I missed "unset" statement.

As for the memory-limit problem it was a bug indeed. See bug #20802.

 [2003-01-21 08:26 UTC] iliaa@php.net
The memory limit option will not take effect unless you've compiled your PHP with --enable-memory-limit.

 [2003-01-21 09:36 UTC] moriyoshi@php.net
The PHP scripting engine (ZendEngine) doesn't perform conservative GC, and 
any referenced object are marked as alive. Therefore there are some cases
where the objects such as mutually-referenced ones remains undestroyed even
though they are unreachable from the root set of variables. Your bi-directional
linked list example is just one of such cases.

 [2003-02-04 16:51 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2003-02-06 04:38 UTC] peter dot karl dot mueller at gmx dot de
--enable-memory-limit works fine.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 16:01:34 2025 UTC