本文介绍了自动重启MathKernel-Mathematica中可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题来自最近的问题"正确设置上限的方法Mathematica 会使用内存吗?"

This question comes from the recent question "Correct way to cap Mathematica memory use?"

我想知道,是否可以通过编程方式重新启动MathKernel,以保持当前的FrontEnd进程连接到新的MathKernel进程,并在新的MathKernel会话中评估一些代码?我的意思是透明"重启,它允许用户继续使用FrontEnd,同时使用来自先前内核的一些代码来评估/评估新的MathKernel进程吗?

I wonder, is it possible to programmatically restart MathKernel keeping the current FrontEnd process connected to new MathKernel process and evaluating some code in new MathKernel session? I mean a "transparent" restart which allows a user to continue working with the FrontEnd while having new fresh MathKernel process with some code from the previous kernel evaluated/evaluating in it?

该问题的动机是要有一种方法,在占用过多内存的情况下自动重启MathKernel,而不会中断计算.换句话说,计算应在新的MathKernel过程中自动继续进行,而无需与用户进行交互(但应保持用户与 Mathematica 进行交互的能力).当然,在新内核中应评估哪些代码的细节是特定于每个计算任务的.我正在寻找一种通用的解决方案,如何自动继续计算.

The motivation for the question is to have a way to automatize restarting of MathKernel when it takes too much memory without breaking the computation. In other words, the computation should be automatically continued in new MathKernel process without interaction with the user (but keeping the ability for user to interact with the Mathematica as it was originally). The details on what code should be evaluated in new kernel are of course specific for each computational task. I am looking for a general solution how to automatically continue the computation.

推荐答案

来自Arnoud Buzing的评论昨天,在Stack Exchange Mathematica聊天中,全部引用:

From a comment by Arnoud Buzing yesterday, on Stack Exchange Mathematica chat, quoting entirely:

在笔记本中,如果您有多个单元格,则可以单独将退出"放在一个单元格中并设置此选项:

In a notebook, if you have multiple cells you can put Quit in a cell by itself and set this option:

SetOptions[$FrontEnd, "ClearEvaluationQueueOnKernelQuit" -> False]

然后,如果您在其上方和下方都有一个单元格,然后选择所有三个单元并进行评估,内核将退出,但前端评估队列将继续(并为最后一个单元重新启动内核).

Then if you have a cell above it and below it and select all three and evaluate, the kernel will Quit but the frontend evaluation queue will continue (and restart the kernel for the last cell).

-阿努德(Arnoud Buzing)

-- Arnoud Buzing

这篇关于自动重启MathKernel-Mathematica中可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 15:49