MATLAB Answers

out of memory matlab runtime 2015b

20 ビュー (過去 30 日間)
elad sertshuk
elad sertshuk 2020 年 1 月 13 日
回答済み: Andrew Janke 2020 年 1 月 31 日
Hey, I'm working on a 32bit windows pc, running matlab 2015b runtime, i am trying to run couple of functions through compiling it into dot net DLL, then running it from my C# program.
i am running into an "out of memory" matlab exception, my c# program is still fine, the pc has more than enough free memory when running it ( over 1.6GB free memory) , the algorithm + MCR takes about 500-600 mb of memory .
i've tried to increase the JVM heap size, or alter the runtime settings, but without any real progress.
does anyone know any pc / matlab compiler/runtime setting that will help me with this issue?
p.s on my 64bit pc running this ( as 32bit app ) i have no issues at all.
thanks in advance.

  0 件のコメント

サインイン to comment.

回答 (1 件)

Andrew Janke
Andrew Janke 2020 年 1 月 31 日
Hard to say without knowing what operations your program is doing. But since you have a lot of free memory left, you might be running in to memory fragmentation problems rather than outright memory exhaustion. When you allocate a Matlab array, it gets carved out of the existing memory space. When you clear that array, the memory gets released back to the pool (at the C malloc level). But that chunk doesn't necessarily get coalesced with the other freed chunks to produce bigger chunks. If you allocate a lot of arrays over time, that can fragment your memory into small chunks so that you can no longer allocate large arrays, even though you have lots of memory available to you in aggregate.
The matlab function memory() will give you some stats that help you diagnose this. Have your program run that and display the results. Look for the "Maximum possible array"/`MaxPossibleArrayBytes` value. If that's a lot smaller than the total memory you have available to you, then you've got fragmentation.
Unless the Out of Memory error you're getting specifically says that it is a Java heap OOM (as opposed to a regular OOM), don't bother messing with your Java settings; that won't do anything.
Unfortunately, fixing memory fragmentation requires modifying your code to just allocate fewer arrays in the first place. Cellstrs, strings, and cells or objects containing many small arrays are a common culprit for fragmentation. Switching to categorical arrays and tables can help a lot there.
As for the 32-bit app working fine on a 64-bit OS: IIRC, on 32-bit Windows, the OS reserves the top half of virtual memory space for itself, so user programs only get 2 GB of RAM to work with. But on 64-bit Windows, this is removed, so 32-bit programs get a full 4 GB of virtual memory space to work with. That might be enough to get you over the threshold where this works. There is a kernel setting on 32-bit Windows to modify things so user programs get 3 GB instead of 2 GB, which may also help you. (Google "Windows 3gb switch" for details.)

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

製品


リリース

R2015b

Translated by