php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80373 Memory leak in big array of strings
Submitted: 2020-11-16 01:27 UTC Modified: 2020-11-20 17:28 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: p30neo at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: Arrays related
PHP Version: 7.4.12 OS: CentOS 7
Private report: No CVE-ID: None
 [2020-11-16 01:27 UTC] p30neo at gmail dot com
Description:
------------
There is Memory leak when we do any string operation in big loops with an array.


Test script:
---------------
Example 1 (Normal):
http://sandbox.onlinephpfunctions.com/code/f597ef30c9f326be47e5822f4276b35a3efa8e86
We have about 66 MB RAM Usage.
----------------
Example 2 (Memory leak):
http://sandbox.onlinephpfunctions.com/code/af719f898c102cdb12d197d06119b05a6765f65d
here we get an error and It will use more than 128MB in this example.
(in example 2 : when we reexecute more times , the memory usage will dcreasing...)


Expected result:
----------------
I expected no memory usage diffrence between those two examples.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-20 17:28 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-11-20 17:28 UTC] cmb@php.net
The second script requires more memory, because there are
2,000,000 distinct "Lorem ipsum" strings.  For the first example,
the engine optimizes to only use only *one* "Lorem ipsum" string
(it is interned), and as such requires far less memory.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jan 25 05:03:35 2022 UTC