Mathlink内存使用累积
我使用 MathLink 从 C++
应用程序以字符串形式发送和接收独立的 mma 表达式。
std::string expression[N];
// ...
for(int i = 0; i < N; ++i) {
MLPutFunction(l, "EnterTextPacket", 1);
MLPutString(l, expression[i].c_str());
MLEndPacket(l);
// Check Packet ...
const char* result;
MLGetString(l, &result);
// process result ...
MLDisownString(l, result);
}
我希望 MLDisownString 释放已用内存,但事实并非如此。
有什么想法吗?
I use MathLink
to send and receive independent mma expressions from a C++
application as strings.
std::string expression[N];
// ...
for(int i = 0; i < N; ++i) {
MLPutFunction(l, "EnterTextPacket", 1);
MLPutString(l, expression[i].c_str());
MLEndPacket(l);
// Check Packet ...
const char* result;
MLGetString(l, &result);
// process result ...
MLDisownString(l, result);
}
I would expect that MLDisownString
frees the used memory except that it doesn't.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的。将此作为答案发布,因为我相信您使用版本 5 或更低版本的几率非常低:
检查它 这里
Ok. Posting this as an answer, because I believe the odds you are using version 5 or below are pretty low:
Check it here
首先,我应该指出这样的参数
$HistoryLength
。将其设置为零通常可以大大减少内存需求:同时,MathKernel 进程的已知问题是它会在长时间计算中累积系统内存并且不会释放它。
最终解决问题的唯一方法是在占用过多内存或可用物理内存量变得太小时重新启动内核。该任务可以自动化。
如果您还没有尝试过 Mathematica 8,那么可能值得一试,因为 根据 Oliver Ruebenkoenig:
但我还没有尝试过版本8,不能对此说什么。
First of all, I should point out such parameter as
$HistoryLength
. Setting it to zero often allows to reduce memory requirements considerably:At the same time, it is known problem with the MathKernel process that it accumulates system memory in long computations and does not release it.
The only way to ultimately solve the problem it to restart the kernel when it takes too much memory or when the amount of available free physical memory becomes too small. This task can be automatized.
If you have not tried Mathematica 8 yet, it may be worth a try, since, according to Oliver Ruebenkoenig:
But I have not tried the version 8 yet and cannot say anything on it.