-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak caused by meminfo_dump #81
Comments
Thanks @squio for this report, We have some tests to make sure we don't leak: https://github.com/BitOne/php-meminfo/blob/master/extension/php7/tests/dump-memory_leak.phpt But it seems it's not sufficient enough. Do you have the same problem on a more recent version of PHP? Can you try without xdebug enabled? And finally, do you have any code that you can provide so I can do some testing? Thank you very much! |
Hi there, speaking of that test (
An example fail output from EL6 PHP 7.2:
edit: added php 7.3 to results |
@jc21 I am having the same problem on CentOS 6.9 running PHP 7.1.11. Tried it on a Docker container based on I was already having this issue from my PHP routines, which led me to try out this repo. The exact same amount of memory is leaking in the test (2097152 bytes), so I am thinking this might be something OS or PHP specific. |
I've implemented the builds on a different hardware and now I'm getting different results:
So my best guess is that this test is defunct in some way ¯_(ツ)_/¯ |
I managed to build a Docker image that is able to reproduce this issue. docker pull gusantoniassi/php-meminfo-memory-leak-bug
docker run -it --rm gusantoniassi/php-meminfo-memory-leak-bug bash
cd /opt/php-meminfo/extension/php7
make test
# test dump-memory_leak.phpt should fail As you can see from the Dockerfile the installation is pretty minimal, so I believe it is either an issue with EL6 or with the |
Looks like
meminfo_dump
itself causes unreported memory leaks.Background: I tried to trace back a memory leak to a suspected XMLDom issue by running a method call in a loop, but then noticed that the actual memory usage was caused by
meminfo_dump
in this specific case.Isolated test code (part of a big Laravel command, but run in isolation):
This results in the following output:
So about 330 kB wasted on each iteration.
See below for meminfo output for 1st and last iteration.
After commenting out the line
meminfo_dump(...)
the following - expected - output is returned:Inspection of the meminfo dumps shows the same trend for overall memory usage but does not show any detail of where the memory went; this is consistent with the documentation which states that memory in extensions is not shown.
NOTE: this is based on a legacy version of PHP 7.0.30 which we need for an existing Laravel 5.5 based project; meminfo was built from source from the master branch today.
meminfo summary, first iteration:
meminfo summary, final iteration:
The text was updated successfully, but these errors were encountered: