-
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
Objects that are still in memory but not shown by php-meminfo #63
Comments
I have found this tool to be pretty interesting - but it does seem to miss a lot more than it catches. I am using php 7.1.17 and applied the linked patch (significant help - thanks :)). With some modifications to the summary cli to illustrate, from a dump of a cli process:
By summing the data the summary table contains, it seems that in this test example I was only able to account for 377841 bytes, out of 10607152 - less than 4%. Or am I misrepresenting the data in the output from php-meminfo? |
The way I understand it, php-meminfo currently works by walking the current call stack and inspecting the symbol tables available for each stack frame. Any array and object that it encounters is inspected in detail. That works for many cases, but I think it wont find things like:
|
I am having similar issue in my PHP 7.1.12, will that branch be merged any time soon? |
@AD7six are you able to share you your modifications to the summary? Thanks. |
I'm in a similar predicament. The amount of memory reported by |
This project seems to be dead, the author does not respond and it does not even work out of the box with php 7.1 it. The fix suggested by @mathieuk is not merged, but I still doubt its accuracy. I tried it with one of my laravel applications and it for sure was not reporting the info correctly. |
Sorry guys, I was on holidays, this happens ;) I will have a look a the reported problem ASAP. |
@mathieuk is right on his description. The memory managed by the extension, and not linked to a PHP variable, will not get accounted into the summary. And by the way, the previous version of this extension use the object store to get all the buckets. But this solution has several shortcomings:
So walking through the execution frame was the best way to get all items really in memory AND still attached to living references. |
@BitOne thanks for your response. Good to see it is still active :-). I was trying to figure out some memory leaks in PHP-PM project, and you can follow up the meminfo output here in this thread. |
If i recall correctly, with my laravel issue, i had plenty of objects still in the object store that were not reachable through the callstack. So maybe the right way is to take everything in the object store and everything in the callstack ( while taking care not to count the same object twice ) ? That would leave collectible objects - maybe the meminfo ext could enable the gc in RINIT and run gc_collect_cycles() before returning the results from the meminfo function?
… Op 7 aug. 2018 om 11:27 heeft Aftab Naveed ***@***.***> het volgende geschreven:
@BitOne thanks for your response. Good to see it is still active :-). I was trying to figure out some memory leaks in PHP-PM project, and you can follow up the meminfo output here in this thread.
php-pm/php-pm#382
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@mathieuk : if you get objects from the objets store, you will get as well the objects that are collectible by the GC. And as the point of the extension is to track memory leak, I would say that objects that are collectible, so will be free soon by the GC, are out of scope. |
@aftabnaveed : Thanks, I had a look at the thread on php-pm. It seems that the issue has been fixed on php-pm side. But the remark from @andig on this thread, about having multiple Application instances. So something is definitely fishy here. |
Yes, it turned out to be a different issue, I guess meminfo was still not reporting it accurately. |
I will try to install Laravel and see if I'm able to reproduce the "multiple application instances" issue. |
Validates that #63 fixes the frame browsing bug in PHP7
@mathieuk, the initial question boils down to this: extensions use internally a lot of memory. Same thing for the Zend Engine itself (to compile PHP scripts, for the VM execution, etc...). Some parts of this memory consumption are done through PHP objects. These objects are accessible through the objects store. But the main part of the memory consumption comes from hashtables, specific structures and scalars that are managed inside these extensions, and so there's no way to access them and dump them. So maybe there's no point of getting objects unrelated to the PHP program itself, and maybe worse, it could give the false belief that we can provide a full insight on the memory used by the extension, whereas we can only provide a very incomplete view. Even giving the information of memory used by the whole system confuses people (see #63 (comment)) for example, where they try to compare it to the memory used by the data manipulated by their program. So I'm not sure we should go that way. Or maybe removing altogether this information from the dump, if it's too much confusing. |
I'm closing this issue, as it was the starting point of a lot of different subjects, on 3 different bugs and 1 misunderstanding of the memory usage information. The 3 bugs have been fixed, and I have released a new v1.0.2 version. @mathieuk : if you can reproduce the same problem as the initially mentioned with this new version, can you create a new issue please? Ideally, having the possibility to reproduce this bug on my side would help a lot. Thank you! |
I tried using php-meminfo in finding out why in a specific case PDO connections were being kept open. PDO connections only close when they end up out of scope without a refcount so I kinda knew where to look.
After addressing some issues ( #62 ) and even adding a little object store dumper to this extension (see paste below) I noticed that even though php-meminfo wasn't showing me these instances, they were still actively in memory.
This problem occured in a Laravel+Laravel Doctrine project. I suspect that these PDO instances might be referenced in closures somewhere? But maybe they're referenced in a different call stack? Is there any way we could have php-meminfo actually find references to these objects somehow?
Attachment, overly simple object_store_dump():
The text was updated successfully, but these errors were encountered: