I don't believe this is possible, no.
The only way to provide detection would be to check for it proactively, e.g. check [man]memory_get_usage/man before a memory-intensive operation, calculate an estimate of how much additional memory you'll need (don't forget to add a little padding, of course), and see if this estimate will fit in memory. If so, continue as normal. If not, don't attempt the operation (obviously).