Bug #79504 [NEW]: json_decode memory leak
From: lyrixx at lyrixx dot info
Operating system: linux
PHP version: 7.4.5
Package: *General Issues
Bug Type: Bug
Bug description:json_decode memory leak
Description:
------------
Hello
I notice a bug in json_decode().
With the following script, the memory is not reclaimed.
But if I use json_decode($content, true); the memory is well
reclaimed.
By the way, I'm not sure it's an issue with JSON, may be it's only about
objects
Test script:
---------------
<?php
ini_set('memory_limit', -1);
function m()
{
echo round(memory_get_usage() / 1024 / 1024, 2) . "\n";
}
m();
$content =
file_get_contents('https://gist.githubusercontent.com/lyrixx/3542faea462e5d101d0d755886ea79bd/raw/b83466f2dc61348e414d3507eeb5740f7751e8f3/file.json');
m();
$data = json_decode($content);
m();
unset($content, $data);
m();
gc_mem_caches();
m();
gc_collect_cycles();
m();
Expected result:
----------------
0.56
75.01
754.69
0.56
0.56
0.56
Actual result:
--------------
0.56
75.01
817.65
16.55
16.55
16.55
--
Edit bug report at https://bugs.php.net/bug.php?id=79504&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79504&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79504&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79504&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79504&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79504&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79504&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79504&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79504&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79504&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79504&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79504&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79504&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79504&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79504&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79504&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79504&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79504&r=mysqlcfg
Thread (3 messages)
- lyrixx at lyrixx dot info