5

我有一个有点类似的问题: Mathematica running out of memory

我对这样的事情感兴趣:

ParallelTable[F[i], {i, 0, 14.9, 0.001}]

哪里F[i]是一个复杂的数值积分(我还没有找到一种简单的方法来重现这个问题,而无需对积分进行页面填充定义)。

我的问题是子内核在内存中爆炸,如果我不让机器交换,我必须停止评估。

但即使我已经停止评估,内核也不会释放它们占用的内存。

ClearSystemCache[] 

我什至试过

ParallelEvaluate[ClearSystemCache[]]

ParallelEvaluate[MemoryInUse[]]

停留在

{823185944, 833146832, 812429208, 840150336, 850057024, 834441704, 
847068768, 850424224}

似乎所有内存控制只适用于主内核?到目前为止,唯一的方法是关闭所有内核并重新启动它们。

我真的希望有一些解决方案......非常感谢。

4

2 回答 2

3

Memory control works for the kernel where control expressions involving such functions as MemoryConstrained, MemoryInUse, Clear, Unset, Remove, $HistoryLength, ClearSystemCache etc. are evaluated. It seems that in your case the source of the memory leaks is not due to Mathematica's internal caching mechanism (thanks for the link, BTW!).

Have you tried to evaluate $HistoryLength=0; in all subkernels before using them for computations? If you have not yet, I strongly recommend to try.

Since you are working with numerical integration functions, I suggest also to try to optimize usage of them. For example, if you make numerical integration using NDSolve and need only a limited set of calculated points (or even the only one point) you should use the form NDSolve[eqns,y,{x,x_needed_min,x_needed_max}] (or even NDSolve[eqns,y,{x,x_max,x_max}]) instead of NDSolve[eqns,y,{x,x_min,x_max}] or NDSolve[eqns,y,{x,0,x_max}]. This can dramatically reduce memory usage in some cases! You can also use EventLocator for memory control.

于 2011-07-24T06:05:31.643 回答
0

我(是?)有完全相同的问题,几乎是逐字逐句。我只是幸运地将选项添加到问题积分中:

Method-> {"GlobalAdaptive", "SymbolicProcessing"->False}

如果您愿意,您可能可以选择任何其他方法,但我在过去几分钟内就成功了。此外,我以前遇到的许多令人讨厌的不一致都消失了,集成进行得更快。

于 2011-08-18T22:26:33.783 回答