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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2020 The PHP Group
All rights reserved.
Last updated: Mon Mar 30 20:01:24 2020 UTC