php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75555 Memory leak in array
Submitted: 2017-11-22 20:21 UTC Modified: 2017-12-16 21:15 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: invader22 at yandex dot ru Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 7.0.25 OS: Linux, Ubuntu 16.04
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: invader22 at yandex dot ru
New email:
PHP Version: OS:

 

 [2017-11-22 20:21 UTC] invader22 at yandex dot ru
Description:
------------
* memory leak in version 7.0+ (7.0.22 from repository ubuntu 16.04; 7.1.5 from sources, minimal configuration)

Test script:
---------------
$a = array();
for ($j = 1; $j <= 3; $j++) {
  for ($i = 0; $i < 50000; $i++) {
    $a[] = range(0, 10);
  }
  echo "Memory: ", (memory_get_usage(true) / 1024), " KiB\n";
  $a = null;
  unset($a);
  $a = array();
  echo "Memory: ", (memory_get_usage(true) / 1024), " KiB\n";
}

Expected result:
----------------
Memory: 92160 KiB
Memory: 768 KiB
Memory: 92160 KiB
Memory: 768 KiB
Memory: 92160 KiB
Memory: 768 KiB

Actual result:
--------------
Memory: 36868 KiB
Memory: 34816 KiB
Memory: 36868 KiB
Memory: 34816 KiB
Memory: 36868 KiB
Memory: 34816 KiB

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-16 21:15 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2017-12-16 21:15 UTC] nikic@php.net
The memory manager caches allocated blocks. You can run gc_mem_caches() to reclaim them.

Unless you are specifically interested in investigating allocator caching behavior, do not pass true to memory_get_usage().
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 05:01:33 2025 UTC