How many input parameters does "mxMalloc" take in and how is memory alignment handled in MATLAB R2023b?

5 views (last 30 days)
I have been using the "mxMalloc" function on MATLAB R2022b with Visual Studio 2019 compiler and have been providing 2 arguments to the function – memory size and alignment. However, upon upgrading to MATLAB R2023b and Visual Studio 2022 compiler, it throws an error saying the function accepts only 1 argument for memory size.
How do I ensure memory alignment in this case?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 4 Nov 2025 at 0:00
Based on all existing documentations for the "mxMalloc" function, the function takes in only one parameter for memory size. Certain compilers like MinGW would directly throw an error for excessive parameters, however some Visual Studio compilers throw a silent warning for the same which can be viewed by using the following command in MATLAB Command Window:
>> mex -v
Here are the documentation links for MATLAB R2022b and R2023b releases to verify that there is no change in the function implementation.
In terms of memory alignment, MATLAB automatically handles this and assigns memory based on system OS an architecture in the following manner:
  1. On Intel architectures, "mxMalloc" returns 32-byte aligned memory.
  2. On Apple Silicon (maca64 architecture in MathWorks parlance), "mxMalloc" returns 16-byte alignment.

More Answers (0)

Tags

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!