BitOne / php-meminfo

PHP extension to get insight about memory usage
MIT License
1.08k stars 78 forks source link

Implement auto dump on out-of-memory #123

Open tortis opened 2 years ago

tortis commented 2 years ago

Two new INI settings have been added called meminfo.dump_on_limit and meminfo.dump_dir. When dump_on_limit is enabled, meminfo will attempt to create a heap dump when an OOM error is detected in the dump_dir directory.

OOM errors are detected by registering an error handler, then checking for a prefix of "Allowed memory size of" on the error message.

resolves #122

tortis commented 2 years ago

@BitOne When I did my original implementation, I did some testing with a real world scenario, but I haven't done that yet with this implementation.

I did test some trivial examples (and added a test for it). My main concern is if we'll get a secondary OOM error when we try to dump a very large "real world" heap. Hopefully changing the memory limit before we try the dump will handle this though. :crossed_fingers: