Contenido principal

Reduce MATLAB Runtime Size

MATLAB® Runtime contains the libraries needed to run compiled MATLAB applications, and MATLAB Compiler SDK™ was designed to work with a large range of applications that use the MATLAB programming language. Because of this, run-time libraries are large. You can reduce the size of a MATLAB Runtime installation by creating custom installers that include only the components needed to run your applications, or by using Docker® images.

Reduce MATLAB Runtime Size Using Custom Installers

You can use the compiler.package.installer function to create an installer that installs a compiled application and optionally MATLAB Runtime. If you choose to include MATLAB Runtime in the installer, the installer reduces disk space usage by installing only the MATLAB Runtime components needed to run the specified application.

Starting in R2024b, you can use the compiler.runtime.customInstaller function to create a custom MATLAB Runtime installer with a minimal size footprint that can run multiple applications.

If you use multiple installers sequentially, MATLAB Runtime is updated to contain the minimal subset of components across all of the installers. This means that you can run multiple MATLAB Compiler™ generated artifacts with the same minimal instance of MATLAB Runtime by using installers created from each build.

Additionally, starting in R2024b, GPU libraries are no longer required dependencies for MATLAB Runtime. Packaged MATLAB code that does not display graphical output can be run using a MATLAB Runtime installation without GPU libraries. You can use compiler.package.installer or compiler.runtime.customInstaller with the OptionalDependencies option set to "none" to exclude optional dependencies such as GPU libraries. (since R2025a)

Reduce MATLAB Runtime Size Using Docker Containers

Since R2023b

You can use the compiler.runtime.createDockerImage function to build a custom image containing only required MATLAB Runtime components. After creating the custom Docker image, use it as the runtime image layer when creating an application Docker image using compiler.package.docker or compiler.package.microserviceDockerImage (MATLAB Compiler SDK). Docker provides a lightweight containerized environment for running one or more compiled MATLAB applications.

Starting in R2024b, a MATLAB Runtime Docker image without GPU support is hosted on the MathWorks® Docker repository. For more information, see MATLAB Runtime Containers.

See Also

|

Topics