3
$\begingroup$

The series depends on a parameter. I numerically calculate consecutively series for different values of the parameter. When Mathematica finishes the calculation of the first point the memory used is enlarged and after some point there is not enough memory (8Gb) for the calculation to proceed and my computer hangs. I see that Mathematica does not release the memory after finishing calculation of first point, though it does not need this information for calculation of second point. Is it possible to make Mathematica to release memory after calculation the first point? Maybe there is operator to do this?

I am using Mathematica 11 on Linux.

I used the following definitions

α[z_, p_] := 1/(1 + (z/p)^2); 
λa = 0.0591966130391084; 
ηgr = 0.0114; dgr = 0.3345; q = 2.74 10^-6 ;
Matm1[n_, x_, a_, η_, T_] := 
  8(q T a)^3 n^3 x^2 E^(-2(q T a) n x) α[q T n, λa] (η x (1-1/(2x^2)))/(1 + η x)
fr1[n_, a_, η_, T_] := 
  NIntegrate[Matm1[n, x, a, η, T], {x , 1, ∞},
    Method -> {"LocalAdaptive", "SymbolicProcessing" -> False}]

Then I had the computer make the following calculations:

nn = {};
Do[tt = {1 + k/2, Sum[fr1[n, 1 + k/2, ηgr, 3], {n, 1, 5 10^5}]}; 
Print["a = ", 1 + k/2, " ", tt]; 
AppendTo[nn, tt], {k, 0, 18}]

Usually for k = 4 computer hangs due to memory expired.

$\endgroup$
6
  • $\begingroup$ Please provide your code. $\endgroup$
    – corey979
    Sep 5, 2016 at 22:03
  • $\begingroup$ @corey979 I added code $\endgroup$
    – nail
    Sep 5, 2016 at 22:36
  • $\begingroup$ Are you re-evaluating the 2nd block of code multiple times? How does k get changed? Do you look at nn to see how it is growing? $\endgroup$
    – m_goldberg
    Sep 5, 2016 at 23:31
  • $\begingroup$ Which version do you use? There is a well-known memory leak in NIntegrate that has persisted at least since version 6 (although I think it was finally fixed in 10.1 or 10.2). $\endgroup$
    – march
    Sep 6, 2016 at 4:34
  • $\begingroup$ Related: (38842); (4322). $\endgroup$
    – corey979
    Sep 6, 2016 at 7:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.