MATLAB: What does it mean to embed a CTF archive

MATLAB Compiler

What does it mean to embed a CTF archive?

Best Answer

Question: What is an embedded CTF archive?
When a CTF archive is embedded, it is included in compiled components and extracted to a temporary folder at runtime. Each instance of your application will have its own sub-directory to which the archive is expanded. This prevents potential corruption from multiple apps accessing the same MCR Cache.
When the archive is not embedded ('-c' flag), it will be expanded in the same directory as the application. It will only be expanded once, so all instances of your application will access the same files. To prevent file corruption, 'deploy locks' are used so only one instance can access the expanded archive at once. This can be disabled by setting the MCR_INHIBIT_CTF_LOCK environment variable, but it is not recommended as it can potentially cause sporadic behavior. If you choose to inhibit the deploy locks, you should make the expanded archive read-only.
Question: Why would I choose _not _to embed a CTF archive?
If lots of instances of your app are running simultaneously, they all need to extract their own CTF archive. This creates a greater time and space cost, which can become worse when the archive is expanded to a networked file system. Using the '-c' flag ensures that the archive is only extracted once, minimizing these costs.