I get this error fairly often and my usual course of action is to switch over to Mathematica 8 which does not get this error. A relatively minimal way to get this error in Mathematica 9 is to run the following three commands:
lambda[t_] := ModularLambda[t]
theta[t_] := EllipticTheta[3, 0, Exp[I Pi t]]
N[-Pi Integrate[
lambda[I x]^4 theta[I x]^4 lambda[I x] (1 - lambda[I x]), {x, 0,
Infinity}], 30]
In Mathematica 8 this integral calculates without any problems. The two definitions are needed to replicate this error for some reason. My suspicion is that it has something to do with the complexity of the integrand.
I have been trying a different workaround which has helped in some instances. If I compile the integrand, the MemoryAllocationFailure
goes away and is replaced with another error that I can sometimes fix:
Block[{integrandCompiled, integrandDeferred},
integrandCompiled =
Compile[{x},
N[lambda[I x]^4 theta[I x]^4 lambda[I x] (1 - lambda[I x])]];
integrandDeferred[x_ /; NumberQ[x]] := integrandCompiled[x];
-Pi NIntegrate[integrandDeferred[x], {x, .1, 10},
PrecisionGoal -> 30]
]
This code gets the right answer but generates error messages. With integration, I usually throw away the result if I get any error because I have seen integration results that are completely wrong when errors occur during the integration.