COMSOL with MATLAB大量循环时内存溢出
1、问题描述:
使用COMSOL with MATLAB时,在脚本中编入了一个大规模的循环,刚开始计算没问题,可是经过长时间循环后,要么就停滞不动,要么就提示错误,其中有错误提示:
Error using com.comsol.model.impl.SolverSequenceImpl/runAll
Java exception occurred:
Exception:
java.lang.OutOfMemoryError: Java heap space
(rethrown as com.comsol.util.exceptions.FlException)
(rethrown as com.comsol.util.exceptions.FlException)
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
The following feature has encountered a problem
The following feature has encountered a problem
Error in multiphysics compilation
- Feature: compile equation: steady (sol1/st1)
- Error: Error in multiphysics compilation.
2、解决办法:
故障分析:出现这种错误的可能原因是Java虚拟机的内存堆不足。由于COMSOL缺省情况下会将所有的操作指令记录在脚本中,这样会导致在大量的脚本操作中,占用了内存空间,使得内存不足,或者使得运行速度急剧下降。
解决办法:停止记录脚本历史指令,通过类似如下指令来完成,model.hist.disable。
可以查阅LiveLink for MATLAB的User’s Guide的第171页中Improving Performance for Large Models。
http://question.cntech.com.cn/COMSOL/comsol21/comsol21_28.html