Why does code generated using MATLAB Coder call the "emxEnsureCapacity" function even when I have disabled variable sizing?
조회 수: 2 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2016년 11월 14일
답변: MathWorks Support Team
2016년 11월 14일
When I generate code for a MATLAB function using MATLAB Coder, I notice calls to a function "emxEnsureCapacity" in the generated code. I understand that this function is called when working with variable-sized arrays. I have no variable sized arrays in my MATLAB function, and I have also unchecked the 'Enable variable sizing' option in the MATLAB Coder settings. Why, then, are there still calls to the "emxEnsureCapacity" function? I believe this is slowing down the speed of the generated code.
채택된 답변
MathWorks Support Team
2017년 1월 9일
In case you are working with fixed size arrays and would like to prevent calls to "emxEnsure Capacity", in the memory settings, please change the 'Dynamic Memory Allocation' option from 'For all variable sized arrays' to 'Never'. This will result in faster run times for the generated code.
Note that there are two different 'Settings' profiles in the MATLAB Coder app - one in the Check for Run Time Issues page (appears as 'Settings'), and one in the Generate Code page (appears as 'more settings') . These represent two entirely different 'Settings' profiles, with the first Settings profile being used for generating the MEX file and checking for runtime issue, while the second one is used to actually generate the code. Therefore, any settings changes made in the 'Check for Run time issues' page, must also be made in the 'Generate Code' page for it to be reflected in the generated code. Hence, be sure to set Dynamic Memory Allocation to 'Never' in both these pages.
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!