调用 MATLAB JA Builder 编译组件时出现内存不足错误

发布于 2024-12-04 06:16:08 字数 855 浏览 0 评论 0原文

我在使用 Java 调用 MATLAB JA Builder 编译代码时遇到了一个奇怪的问题。详细信息如下:

  1. 代码对大型 .mat 文件执行 load()
  2. 如果在 MATLAB 中打开 mat 文件(通过导入 .mat),则一切正常,并占用约 900MB 的空间内存
  3. 如果从Java应用程序调用代码(它只是导入由JA Builder构建的函数),我会从MATLAB脚本中耗尽内存
  4. 我尝试将Xmx设置得非常高,但这似乎根本没有做任何事情
  5. 更奇怪的是如果 java 程序通过 Eclipse 调试器运行,它最多可以使用 900MB 的 RAM 并且 load() 函数成功

有谁知道会发生什么?


我附上了堆栈跟踪的一部分:

??? Error using ==> load
Out of memory. Type HELP MEMORY for your options.

... Matlab M-code Stack Trace ...
file C:\Users\HiME\AppData\Local\MathWorks\mcr_cache_v78\fileProcesso_39586D5669D9A968B2CD5231A43620E4\fileProcesso\getHeaders.m,name getHeaders,line at 8.
com.mathworks.toolbox.javabuilder.MWException: Error using ==> load
Out of memory. Type HELP MEMORY for your options.Error in =>getHeaders.m at 8

I'm having a strange problem with calling a MATLAB JA Builder compiled code in Java. Details are as follows:

  1. The code does a load() on a large .mat file
  2. If the mat file was opened in MATLAB (by importing the .mat), everything works fine and takes up ~900MB of memory
  3. If the code is called from an Java app (which simply imports the function built by JA Builder), I get out of memory from the MATLAB script
  4. I have tried setting Xmx really high, but that doesn't seem to do anything at all
  5. What is weirder, is that if the java program is run through the Eclipse debugger, it can use up to 900MB of ram and the load() function succeeds

Does anyone know what could be happening?


I have attached a part of the stack trace:

??? Error using ==> load
Out of memory. Type HELP MEMORY for your options.

... Matlab M-code Stack Trace ...
file C:\Users\HiME\AppData\Local\MathWorks\mcr_cache_v78\fileProcesso_39586D5669D9A968B2CD5231A43620E4\fileProcesso\getHeaders.m,name getHeaders,line at 8.
com.mathworks.toolbox.javabuilder.MWException: Error using ==> load
Out of memory. Type HELP MEMORY for your options.Error in =>getHeaders.m at 8

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖乖 2024-12-11 06:16:08

尝试设置 -Xmx lower

在常规 Matlab 进程中,内存分为用于 Java 对象的 Java 堆和可用于 Matlab M 数据结构(如加载结果)的其他内存。增大 Java 堆会调整该分界线,将内存从本机代码和 Matlab 的 GC 中夺走,并将其交给 Java。基本上,Java 堆和 Matlab 堆是在内存竞争。在 JA Builder 库中运行的 JVM 可能以相同的方式工作。

检查您在 Eclipse 下运行的堆大小,并将其与 Java 应用程序正常运行的情况进行比较,并尝试减小 Java 堆大小,以为 Matlab 堆保留更多内存。

Try setting -Xmx lower instead.

In a regular Matlab process, the memory is split between the Java heap used for Java objects, and the other memory available to Matlab M data structures like the result of that load. Making the Java heap bigger adjusts that dividing line, taking memory away from native code and Matlab's GC, and giving it to Java. Basically, the Java heap and Matlab heap are in competition for memory. The JVM running inside a JA Builder library probably works the same way.

Check the heap size you're running with under Eclipse and compare it to how your Java app is normally running, and try reducing the Java heap size to reserve more memory for the Matlab heap.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文