Is it possible to find out (programmatically) if the current PHP process is about to run out of memory?
Some Background:
I am the author of the Bulk Delete WordPress plugin, which allows people to delete posts, users etc in bulk.
One common complaint I get from my plugin users is that they get a blank page when trying to delete huge amount of posts. This happens because PHP runs out of memory.
If I can find out that the PHP process is about to run out of memory, then I can try to delete in batches or at least give a warning to the user, instead of just throwing a blank page.
After some more research I found a solution. The solution is to use register_shutdown_function
One drawback is that this function will get executed after PHP ran out of memory and not before (which is still fine with me, since I can just let the users know about it)