Azzera filtri
Azzera filtri

MatLab runtime initialisation is slow

24 visualizzazioni (ultimi 30 giorni)
2018b
We use MatLab as a libraty within our C# application.
We initialise the MatLab runtime and wait for it to finish
WS.mcr.EvaluateFunction(nameof (Initialise), numArgsOut, ref argsOut, argsIn);
This can take 10 to 120 secs. [no change to the library, the varioation can be seen on subsequent starts of the application].
Why does it take so long and why does it vary so much.
Nigel

Risposta accettata

Debarghya Kundu
Debarghya Kundu il 24 Nov 2020
In general MCR initialization takes around the same time (or faster) as starting MATLAB desktop, as it allocates resources and initializes its libraries. The process takes a bit of time due to its many libraries and its overall large size. Currently, there are no settings to reduce the initialization time of MCR.
When there are multiple MATLAB SDK compiler compiled component in one program (.NET assembly, JAVA package, Python package, c++ library), loading every component involves an MCR initialization step. The first MCR initialization will be the slowest, but the others should be much faster. This is because a lot of stuff is shared among all the MCR instances and will be set up by the first MCR instance, including all MATLAB runtime library loading, built-in data type initialization, MATLAB installed m-file tree parsing, java JVM startup and many others.
If the calls are consistently slow, check that its set up in a way where the execution is not cleaned up and recreated so that the MCR does not need to reinitialize. If the current MCR cache root is being cleared, specify a different cache location using the MCR_CACHE_ROOT environment variable. Set the MCR_CACHE_SIZE if the cache is being pruned.
Additionally, upgrading from an HDD to an SSD can improve MCR initialization, as disk usage is sometimes the performance bottleneck.
  1 Commento
Eric Delgado
Eric Delgado il 29 Ago 2023
Hi @Debarghya Kundu, I am struggling with something like this...
If I unload my antivirus (Security Agent), my deployed app open in 10 seconds. But if I load it, my deployed app open in 40 seconds, or 2 minutes or never open (even tough Windows taskmanager register the process).
The villan:
The antivirus reports doesn't show nothing strange... do you have any clue of what do I have to do?
Thanks! :)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su COM Component Integration in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by