Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deployed Matlab application using significantly more memory than Matlab scripts

I was testing a stand-alone application we developed in Matlab when I noticed that its memory usage, according to Windows Task Manager, was peaking several times above 16gb. I decided to run Matlab's profiler with profile -memory on on the scripts behind the compiled version to see where the memory peaks were occurring, using the exact same input. However, the highest peak memory it found was 2400860.00 Kb, or about 1/4 as much, for the function that essentially acts as the program's main().

Thus, I was wondering if people have noticed huge memory usage differences between running a compiled Matlab program and running the original scripts in Matlab. I noticed it took a lot longer running in Matlab, but I figured that was due to the profiler keeping track of all of the memory allocations and deallocations, rather than reading and writing to a swap space on disk.

like image 423
ackrause Avatar asked Jan 30 '13 20:01

ackrause


1 Answers

To make a real quick answer to this question. Yes, MATLAB compiled applications run with more overhead than MATLAB scripts.

This is because MATLAB deployed applications open up a version of MATLAB which is stored in the memory called the MCR. The MCR runs with more overhead than MATLAB.

One thing that I have found useful in situations like this is to recompile and see if that helps at all. If it doesn't, you could try to lower the memory usage by running calculations in segments.

This might be helpful for better memory usage: http://www.mathworks.com/help/matlab/matlab_prog/strategies-for-efficient-use-of-memory.html

Source:

  • http://www.mathworks.com/matlabcentral/newsreader/view_thread/306814
  • Matlab executable too slow

Comment if you have questions.

like image 96
Dan Grahn Avatar answered Sep 21 '22 16:09

Dan Grahn