It's not a quick or easy fix. The patch is a 10000 line nightmare. No really it's actually 10k. A lot of that is test code, but there are also significant changes to deep engine internals.
PHP did really really bad memory limit handling. Now it's only really bad.