Use dynamic memory allocation for model block instantiation
Whether to allocate dynamic memory for instantiating objects for reference models configured with C++ class interface
Model Configuration Pane: Code Generation / Interface
Description
The Use dynamic memory allocation for model block instantiation parameter specifies whether generated code uses the operator new, during model object registration, to instantiate objects for referenced models that are configured with a C++ class interface.
Dependencies
To enable this parameter, set:
- Language to - C++
- Code interface packaging to - C++ class.
Settings
Off (default) | On- On
- Enables generation of code that uses dynamic memory allocation to instantiate objects for referenced models configured with a C++ class interface. During instantiation of an object for the top model in a model hierarchy, the generated code uses - newto instantiate objects for referenced models.- Selecting this parameter frees a parent model from having to maintain information about referenced models beyond its direct children. - If you select this parameter and an out-of-memory error occurs during the use of - new, be aware that the code generator might throw a- bad_allocexception, per the C++ standard. You must provide code to catch and process the- bad_allocexception in case an out-of-memory error occurs for a- newcall during construction of the top model object.
- If you select this parameter 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. Those functions prevent pointer members within the model class from being copied by other code. 
 
- Off
- Disables generation of code that uses - newto instantiate referenced model objects.- If you clear this parameter, a parent model maintains information about its referenced models, including its direct and indirect children. 
Recommended Settings
| Application | Setting | 
|---|---|
| Debugging | No impact | 
| Traceability | No impact | 
| Efficiency | On | 
| Safety precaution | No recommendation | 
Programmatic Use
| Parameter: UseOperatorNewForModelRefRegistration | 
| Type: character vector | 
| Value: 'on'|'off' | 
| Default: 'off' | 
Version History
Introduced in R2009b