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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
50 - 35 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 22:01:26 2024 UTC