Use dynamic memory allocation for model block instantiation
Description
Specify whether generated code uses the operator new
, during model
object registration, to instantiate objects for referenced models configured with a C++
class interface.
Category: Code Generation > Interface
Settings
Default: off
On
Generates code that uses dynamic memory allocation to instantiate objects for referenced models configured with a C++ class interface. Specifically, during instantiation of an object for the top model in a model reference hierarchy, the generated code uses
new
to instantiate objects for referenced models.Selecting this option frees a parent model from having to maintain information about referenced models beyond its direct children.
If you select this option, be aware that a
bad_alloc
exception might be thrown, per the C++ standard, if an out-of-memory error occurs during the use ofnew
. You must provide code to catch and process thebad_alloc
exception in case an out-of-memory error occurs for anew
call during construction of a top model object.If Use dynamic memory allocation for model block instantiation is selected and the base model contains a Model block, the build process might generate copy constructor and assignment operator functions in the private section of the model class. The purpose of the functions is to prevent pointer members within the model class from being copied by other code.
Off
Does not generate code that uses
new
to instantiate referenced model objects.Clearing this option means that a parent model maintains information about its referenced models, including its direct and indirect children.
Dependencies
This parameter appears only for ERT-based targets with Language set to
C++
and Code interface packaging set toC++ class
.This parameter requires an Embedded Coder® license when generating code.
Command-Line Information
Parameter:
UseOperatorNewForModelRefRegistration |
Type: character vector |
Value:
'on' | 'off' |
Default:
'off' |
Recommended Settings
Application | Setting |
---|---|
Debugging | No impact |
Traceability | No impact |
Efficiency | On |
Safety precaution | No recommendation |