- On Intel architectures, "mxMalloc" returns 32-byte aligned memory.
- On Apple Silicon (maca64 architecture in MathWorks parlance), "mxMalloc" returns 16-byte alignment.
How many input parameters does "mxMalloc" take in and how is memory alignment handled in MATLAB R2023b?
조회 수: 5 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2025년 11월 4일 0:00
답변: MathWorks Support Team
2025년 11월 6일 21:56
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?
채택된 답변
MathWorks Support Team
2025년 11월 4일 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.
R2023b: mxMalloc (C and Fortran)
R2022b: mxMalloc (C and Fortran)
In terms of memory alignment, MATLAB automatically handles this and assigns memory based on system OS an architecture in the following manner:
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!