-
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
[Feature request] Allow to automatically create a dump on memory limit #122
Comments
I made an attempt at implementing this feature a while back, with some success. However, I was playing around with learning c and PHP extensions and I went a bit off the rails, so my fork is probably not a suitable contribution to this project. https://github.com/tortis/php-meminfo#enable-dump-on-limit |
I think the changes required to add this feature alone wouldn't be too bad. One problem that I ran into when testing it, was that it was very easy to trigger a secondary OOM error while performing the memory dump triggered by the original OOM error. I attempted to mitigate this problem by converting the "visited items" hash set to not use a PHP (zend) hash which was causing more PHP allocations that can trigger the PHP runtime to OOM again. This might have not been necessary at all, since I think you could just turn off (or increase) the zend memory limit when the first OOM happens. I don't know for sure if that works. For the same reason, I also converted the recursive traversal to iterative with a stack. Most of the other changes on my fork were just random stuff where I was playing with the code and doing light refactoring while trying to understand how it works. @BitOne Is this a feature you'd be interested in adding? I could try an implementation of it with out all the other changes. Or if you'd rather handle it yourself feel free to use any of the work on my branch. |
Hello! That would be a wonderful feature! I remember I discussed it some years ago with Julien Pauli who at that time was release manager of PHP. It's something that exists on the Java Virtual Machine, and it is indeed extremely useful. If that's okay for you @tortis , can you do a PR here? |
I sometimes use the php-memory-profiler with your library to debug memory usage of my projects.
This extension has a nice feature that allows to automatically dump a memory profile when the process crash because of a memory limit.
It could be cool to have this feature for this extension.
The text was updated successfully, but these errors were encountered: