You should be able to check just whether <code>diff > avail_memory</code> at this point.