Is it a good idea to run Matlab in the "background" as a local out-of-process COM server?

1 view (last 30 days)
Background
  1. The cpu has 4 cores
  2. An interactive application, which includes some long computations. The user don't want to wait.
  3. I hesitate to use the Parallel Computing Toolbox.
  4. Windows environment
It seems possible to run Matlab as a "Local Out-of-Process Server" from within Matlab. (I take for granted that Windows will run it in a different core.) So far I run this example, which displays "4".
h = actxserver('Matlab.Application');
msg = h.Execute('a = 2+2;');
a = h.GetVariable( 'a', 'base' );
disp( a )
delete(h)
The idea is to let the user start certain tasks and do something else in the application while the local out-of-process server works in the "background".
Now I wonder whether it is worth while to try to implement this. Which are all the problems and limitations I didn't think of?
The Matlab function, SYSTEM, might be an alternative. However, that has the overhead of starting Matlab for every task.
-------- EDIT ----------
I trippled my example:
h1 = actxserver('Matlab.Application');
h2 = actxserver('Matlab.Application');
...
and learned that only one server is started; h1 and h2 are handles of the same server instance. That came as a surprise to me. I guess it's fundamental to the COM-technology. The Matlab documentation doesn't say that explicitly(?)
.
--- Wishful thinking ---
I learned from the tech support that
It is not possible to return control to the MATLAB
command window while invoking a COM method of an
actxserver application.
Thus, it is not possible to run jobs in the background with help of a local out-of-process Matlab server. However, there is an enhancement request.

Accepted Answer

Jan
Jan on 14 Sep 2011
The method is fine, if you have enough RAM to run two instances of MATLAB. Using SYSTEM allows to start more instances, which would use the cores more efficiently.
If the bottlenecks of your program are multi-threaded (e.g. MIN, MAX, FILTER, etc), all cores are occupied already and there will be no speedup.
  1 Comment
per isakson
per isakson on 15 Sep 2011
Thank you for your answer. I learned that I can only start ONE server instance. You gave me some confidence so I'll try it.

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!