Why does code generated using MATLAB Coder call the "emxEnsureCapacity" function even when I have disabled variable sizing?

2 ビュー (過去 30 日間)
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
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 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by