If you are facing error during inventory closing or cancellation of recalculation then you need to refer below TechNet site:
http://blogs.msdn.com/b/emeadaxsupport/archive/2009/06/15/error-executing-code-insufficient-memory-to-run-script.aspx
If problem still exists then you need to select lesser period range.